现在的位置: 首页 > 综合 > 正文

Java这个程序哪儿错了

2013年07月08日 ⁄ 综合 ⁄ 共 1477字 ⁄ 字号 评论关闭

class Employee {
           String name,id,post;
           long salary;
          public   Employee(String name,String id,String post,long salary){      
            this.name=name;
            this.id=id;
            this.post=post;
            this.salary=salary;}
          void changePost(String newPost) {
             post=newPost;
            }
         void changeSalary(long dev){
             salary=salary+dev;
            }
            void print(){
             System.out.print("工号"+id+"姓名"+name);
             System.out.print("职务:"+post+"月薪:"+salary);
           
           
           }
           public class EmployeeDemo{
            public static void main (String[] args){
             Employee a=new Employee("小于","0029","部门经理",9000);     
             Employee b=new Employee("蚂蚁","0066","部门副经理",6000);
             Employee c=new Employee("网页","0633","职员",3000);

             a.print();
             b.print();
             c.print();
             a.changePost("副总经理");
             b.changeSalary(3000);
             c.changePost("职员");
             b.changeSalary(-3000);
             c.changePost("部门副经理");
             c.changeSalary(3000);
             System.out.println("调整岗位和月薪后:");
             a.print();
             b.print();
             c.print();
            }
           }
          
}
1-如果我在public   classEmployee(String name,String id,String post,long salary){ 就会发生错误(加入class之后),为什么?

2-Employee a=new Employee("小于","0029","部门经理",9000);     错误!哪儿错
             Employee b=new Employee("蚂蚁","0066","部门副经理",6000);
             Employee c=new Employee("网页","0633","职员",3000);

            

抱歉!评论已关闭.