写一个people类
ID,name,job,work,salary,address
行为:
sound(),run(),work(),show time();
创建两个对象,分别就不同的人。填写进去
people类Java
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- piaoyiren 2022-07-16 11:54关注
import java.util.Date; public class People { private Integer id; private String name; private String job; private String work; private Double salary; private String address; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getJob() { return job; } public void setJob(String job) { this.job = job; } public String getWork() { return work; } public void setWork(String work) { this.work = work; } public Double getSalary() { return salary; } public void setSalary(Double salary) { this.salary = salary; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public void sound() { System.out.println(this.name +" is singing"); } public void run() { System.out.println(this.name+" is running"); } public void work() { System.out.println(this.name+" is working"); } public void showTime() { System.out.println(new Date()); } public People(Integer id, String name, String job, String work, Double salary, String address) { super(); this.id = id; this.name = name; this.job = job; this.work = work; this.salary = salary; this.address = address; } public static void main(String[] args) { People p1=new People(1, "zs", "java", "biancheng", 3455.6, "南山"); People p2=new People(2, "lisi", "java", "设计", 3455.6, "南山"); } }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 1无用
悬赏问题
- ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
- ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
- ¥15 cmd cl 0x000007b
- ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
- ¥500 火焰左右视图、视差(基于双目相机)
- ¥100 set_link_state
- ¥15 虚幻5 UE美术毛发渲染
- ¥15 CVRP 图论 物流运输优化
- ¥15 Tableau online 嵌入ppt失败
- ¥100 支付宝网页转账系统不识别账号