weixin_56416078
2021-06-11 16:45 阅读 24

求第三题的代码,使用Intellij IDEA Community Edition软件,感想

 

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

3条回答 默认 最新

  • technologist_36 CSDN专家-sinjack 2021-06-11 16:49

    如有帮助,望采纳。

    public class Dept {
        private String dNo;
        private String deptName;
        private String address;
        public void show(){
            System.out.println("部门编号:"+dNo+",部门名称:"+deptName+",所在位置:"+address);
        }
    }
    
    
    
    import java.util.Date;
    public class Emp {
        private String eNo;
        private String eName;
        private String work;
        private Date employeeTime;
        private float salay;
        private float money;
        private String dName;
    
        public Emp(String eNo, String eName, String work, Date employeeTime, float salay, float money, String dName) {
            this.eNo = eNo;
            this.eName = eName;
            this.work = work;
            this.employeeTime = employeeTime;
            this.salay = salay;
            this.money = money;
            this.dName = dName;
        }
    
        public void setMoney(float money) {
            this.money = money;
        }
    
        public float getMoney() {
            return money;
        }
    
        @Override
        public String toString() {
            return "Emp{" +
                    "eNo='" + eNo + '\'' +
                    ", eName='" + eName + '\'' +
                    ", work='" + work + '\'' +
                    ", employeeTime=" + employeeTime +
                    ", salay=" + salay +
                    ", money=" + money +
                    ", totalMoney=" + (money+salay) +
                    ", dName='" + dName + '\'' +
                    '}';
        }
    
        public static void main(String[] args) {
            Emp emp=new Emp("1001","小白","经理",new Date(),8900,3000,"技术部");
            System.out.println(emp);
            emp.setMoney(3800);
            System.out.println("修改员工补助后:");
            System.out.println(emp);
        }
    }
    

    点赞 1 评论 复制链接分享
  • software7503 CSDN专家-赖老师(软件之家) 2021-06-11 16:49
    
    public class Dept {
    
    	private int deptId;
    	private String deptName;
    	private String address;
    	
    	public Dept() {}
    	public Dept(int deptId,String deptName,String address) {
    		this.deptId = deptId;
    		this.deptName = deptName;
    		this.address = address;
    	}
    	public int getDeptId() {
    		return deptId;
    	}
    	public String getDeptName() {
    		return deptName;
    	}
    	public String getAddress() {
    		return address;
    	}
    	public void printInfo() {
    		System.out.println("部门编号:" + deptId+",部门名称:"+deptName+",地址:" + address);
    	}
    	
    }
    
    点赞 评论 复制链接分享
  • QA_Assistant 有问必答小助手 2021-06-15 17:38

    您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~

    如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~

    ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632

    点赞 评论 复制链接分享

相关推荐