【求助】自定义类方法的问题
rt,以下是代码public class Branch{
String subName;
int salary;
int totalBooks;
int totalHrs;
Branch(String subName1,int totalBooks1 ){
subName=subName1;
totalBooks=totalBooks1;
}
void calculata(){
int totalHrs=totalBooks*2;
System.out.println(subName+"学科的总时数是"+totalHrs);
}
public static void main(String[] args){
Branch Science1=new Branch("科学",10);
Branch Arts1=new Branch("艺术",14);
Science1.calculata();
Arts1.calculata();
System.out.println("----------------------");
Science s1;
s1.printall(Science1);
Arts a1;
a1.printall(Arts1);
}
class Science{
void printall(Branch Science1){
Science1.calculata();
}
}
class Arts{
void printall(Branch Arts1){
Arts1.calculata();
}
}
}
烦请大侠们帮忙看看
[此贴子已经被作者于2007-7-26 20:21:52编辑过]