[attach]423[/attach]
题目很简单~最好在~星期1之给于答案~谢谢了~要是有相关的代码也可以
public class Vehicle{ private char type; private int number; private String time;
public Vehicle(char type,int number,String t){ this.type = type; this.number = number; time = t; }
public void setType(char c){ type = c; }
public char getType(){ return type; }
public String toString(){ String result = ""; result += "The type of the car is: "+type+",the number is: "+number+",enter time: "+time+"."; return result; } }// end of Vehicle class
public class TestCar{ public static void main(String[] args){ Vehicle v = new Vehicle('L', 324563, "07:32:43"); System.out.println(v); } } //end of TestCar class
// I am not sure if this is what you want, but i suspect so :P
public class ClassData { private String name; // you may need this as public private int number; // this as well
ClassData(String theName, int theNumber) { name = theName; number = theNumber; }
public String getName(){ return name; }
public int getNum(){ return number; } }//end of ClassData class
public class AllClass{ ClassData data[] = new ClassData[200]; int classCount = 0;
public void addClass(String theName, int theNumber) { data[classCount] = new ClassData(theName,theNumber); classCount++; }
public int getNumber(String className) { for(int i = 0; i<classCount; i++){ if(data[i].getName().equals(className)) // i am not sure if i can use the accessor method here return data[i].getNum();//also not sure if i can use either } return -1; } }//end of AllClass class
// maybe you can declear String className and int number as public then you dont need the accessor method // but this is kind of unusual i think...