第三次Java作业
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了第三次Java作业相关的知识,希望对你有一定的参考价值。
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作业的主要内容,如果未能解决你的问题,请参考以下文章