1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
import java.util.Scanner; /** * Java_2018_04_11_HW1 * Author:Dragonyue */ class A { int SN; String Name; A() { System.out.println("111"); } A(int SN) { this(); System.out.println("222"); this.SN = SN; } void setName(String Name) { this.Name = Name; } String getName() { return this.SN + "\r\n" + this.Name; } void A(String str) { System.out.print("1個" + str); } void A(String num, String str) { int n = Integer.parseInt(num); System.out.print(num + "個" + str); } } public class Java_2018_04_11_HW1 { public static void main(String[] args) { A aA = new A(333); aA.setName("Howhow"); System.out.println(aA.getName()); Scanner scanner = new Scanner(System.in); String[] str = scanner.nextLine().split(" "); if (str.length == 1) aA.A(str[0]); else if (str.length == 2) aA.A(str[0], str[1]); } } |