计科14-1 140201125 王振禹 作业三
class Address{
private String country;
private String province; //省份
private String city;
private String street;
private int postcode; //邮编
public Address(String country,String province,String city,String street,int postcode){
this.setCountry(country);
this.setProvince(province);
this.setCity(city);
this.setStreet(street);
this.setPostcode(postcode);
}
public void tell(){
System.out.println("国家:"+country+"\n"+"省份:"+province+"\n"+"街道:"+street+"\n"+"邮编:"+postcode);
}
public String getCountry(){
return country;
}
public void setCountry(String c1){
country=c1;
}
public String getProvince(){
return province;
}
public void setProvince(String p){
province=p;
}
public String getCity(){
return city;
}
public void setCity(String c2){
city=c2;
}
public String getStreet(){
return street;
}
public void setStreet(String s){
street=s;
}
public int getPostcode(){
return postcode;
}
public void setPostcode(int p){
postcode=p;
}
}
public class Demo01 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Address addr=new Address("中国","北京","北京","牛富路10号",101301);
System.out.println("国家:"+addr.getCountry());
System.out.println("省份:"+addr.getProvince());
System.out.println("城市:"+addr.getCity());
System.out.println("街道:"+addr.getStreet());
System.out.println("邮编:"+addr.getPostcode());
}
}
class Empiloyee{
private int number;
private String name;
private int jibenprice;
private int zengzhangprice;
public Empiloyee(int number,String name,int jibenprice,int zengzhangprice){
this.setNumber(number);
this.setName(name);
this.setJibenprice(jibenprice);
this.setZengzhangprice(zengzhangprice);
}
public void tell(){
System.out.println("编号:"+number+"\n"+"姓名"+name+"\n"+"基本工资"+jibenprice+"\n"+"薪水增长额"+zengzhangprice);
}
public int getNumber(){
return number;
}
public void setNumber(int n1){
number=n1;
}
public String getName(){
return name;
}
public void setName(String n2){
name=n2;
}
public int getJibenprice(){
return jibenprice;
}
public void setJibenprice(int j){
jibenprice=j;
}
public int getZengzhangprice(){
return zengzhangprice;
}
public void setZengzhangprice(int z){
zengzhangprice=z;
}
public int sum(){
int sum=jibenprice+zengzhangprice;
return sum;
}
}
public class Demo02 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Empiloyee emp=new Empiloyee(140201125,"王振禹",3000,2000);
System.out.println("编号:"+emp.getNumber());
System.out.println("姓名:"+emp.getName());
System.out.println("基本薪水:"+emp.getJibenprice());
System.out.println("薪水增长额:"+emp.getZengzhangprice());
System.out.println("增长后的工资总额:"+emp.sum());
}
}
class Dog{
private String name;
private String color;
private int age;
public Dog(String name,String color,int age){
this.setName(name);
this.setColor(color);
this.setAge(age);
}
public void tell(){
System.out.println("姓名:"+name+"\n"+"颜色"+color+"\n"+"年龄"+age);
}
public String getName(){
return name;
}
public void setName(String n){
name=n;
}
public String getColor(){
return color;
}
public void setColor(String c){
color=c;
}
public int getAge(){
return age;
}
public void setAge(int a){
age=a;
}
}
public class Demo03 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Dog dog=new Dog("牛牛","黑色",1);
System.out.println("姓名:"+dog.getName());
System.out.println("颜色:"+dog.getColor());
System.out.println("年龄:"+dog.getAge());
}
}
设计一个表示用户的User类这题不会