码迷,mamicode.com
首页 > 编程语言 > 详细

第三次Java作业

时间:2016-03-19 19:27:50      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:

public class liti1 {


public static void main(String[] args) {
// TODO Auto-generated method stub
Address a = new Address("中国", "辽宁省", "丹东市", "通江街",
123456);
System.out.println("国家" + a.getCountry() + "、省份" + a.getProvince()
+ "、城市" + a.getCity() + "、街道" + a.getStreet() + "、邮编"
+ a.getPost());
}


}


class Address {
String country;
String province;
String city;
String street;
int post;

public Address(String country, String province, String city, String street,
int post) {
this.setCountry(country);
this.setProvince(province);
this.setCity(city);
this.setStreet(street);
this.setPost(post);
}

public void setCountry(String country) {
this.country = country;
}
public void setProvince(String province) {
this.province = province;
}
public void setCity(String city) {
this.city = city;
}
public void setStreet(String street) {
this.street = street;
}
public void setPost(int post) {
this.post = post;
}

public String getCountry() {
return this.country;
}

public String getProvince() {
return this.province;
}

public String getCity() {
return this.city;
}

public String getStreet() {
return this.street;
}
public int getPost() {
return this.post;
}
}

技术分享

public class liti2{


public static void main(String[] args) {
// TODO Auto-generated method stub
Employee me = new Employee("140201115", "闫昱颖", 5000, 0.1);
System.out.println("编号:" + me.getNumber() + " 姓名" + me.getName()
+ " 基本工资" + me.getBasal() + " 增长率" + me.getIncrease() + " 总工资"
+ me.salary());
}


}


class Employee {
private String number;
private String name;
private double basal;
private double increase;

public Employee(String number, String name, double basal, double increase) {
this.setNumber(number);
this.setName(name);
this.setBasal(basal);
this.setIncrease(increase);
}

public void setNumber(String number) {
this.number = number;
}


public void setName(String name) {
this.name = name;
}


public void setBasal(double basal) {
this.basal = basal;
}


public void setIncrease(double increase) {
this.increase = increase;
}


public String getNumber() {
return this.number;
}


public String getName() {
return this.name;
}


public double getBasal() {
return this.basal;
}


public double getIncrease() {
return this.increase;
}


public double salary() {
return basal * increase;
}
}

技术分享

 

第三次Java作业

标签:

原文地址:http://www.cnblogs.com/yanyuying/p/5295844.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!