import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class Worker {
private int age;
private String name;
private double salary;
public Worker() {
}
public static void main(String[] args) {
List<Worker> workers = new ArrayList<Worker>();
workers.add(new Worker("zhang3",18,3000));
workers.add(new Worker("li4",25,3500));
workers.add(new Worker("wang5",22,3200));
workers.add(2,new Worker("zhao6",24,3300));
workers.remove(3);
for (Worker worker : workers) {
System.out.println("Name:"+worker.getName()+"Age:"+worker.getAge()+"Salary:"+worker.getSalary());
}
Iterator iterator = workers.iterator();
while(iterator.hasNext()){
Worker worker =(Worker) iterator.next();
System.out.println("Name:"+worker.getName()+"Age:"+worker.getAge()+"Salary:"+worker.getSalary());
}
}
public Worker(String name, int age, double salary) {
this.name = name;
this.age = age;
this.salary = salary;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
public void work() {
System.out.println(name + "work");
}
public String toString(){
return name + " " + age + " " + salary;
}
public boolean equals(Worker w){
if(!w.name.equals(name)){
return false;
}
if(w.age != age){
return true;
}
if(w.salary != salary){
return true;
}
return true;
}
}
作业
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 这8种学生永远拿不到高分!早看早受益! 下面是一位资深班主任总结了8种成绩提不上去的原因,分别对应8类孩子,如果你...
- 雅新教育 袁老师图书馆 2017/9/22 你问我答 爱学习给你支招 有人问:作业堆成山,晚自习也写...