java初学者: 这个Java程序有什么问题。貌似提示没有主函数。
publicclassgg{publicstaticvoidmain(Stringargs[]){MyDatemd=newMyDate(2007,3,21);Employ...
public class gg {
public static void main(String args[]) {
MyDate md = new MyDate(2007,3,21);
Employee emp = new Employee("张立",23,1500f,md);
emp.print();
}
}
class Employee{
String name;
int age;
float salary;
MyDate hiredate;
Employee(String n,int a,float s,MyDate h){
name=n;
if(a>=18&&a<=60)
age=a;
else
{
System.out.println("over age !");
System.exit(1);
}
salary =s;
hiredate = h;
}
void print(){
String s_hiredate;
s_hiredate = hiredate.year+"年"+hiredate.month+"月";
System,out,println("姓名"+name+“年龄”+age+“工
资”+salary+“雇佣年月”+s_hiredate);
}
}
class MyDate{
int year,month,day;
MyDate(int y,int m,int d){
year=y;
month=m;
day=d;
}
} 展开
public static void main(String args[]) {
MyDate md = new MyDate(2007,3,21);
Employee emp = new Employee("张立",23,1500f,md);
emp.print();
}
}
class Employee{
String name;
int age;
float salary;
MyDate hiredate;
Employee(String n,int a,float s,MyDate h){
name=n;
if(a>=18&&a<=60)
age=a;
else
{
System.out.println("over age !");
System.exit(1);
}
salary =s;
hiredate = h;
}
void print(){
String s_hiredate;
s_hiredate = hiredate.year+"年"+hiredate.month+"月";
System,out,println("姓名"+name+“年龄”+age+“工
资”+salary+“雇佣年月”+s_hiredate);
}
}
class MyDate{
int year,month,day;
MyDate(int y,int m,int d){
year=y;
month=m;
day=d;
}
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询