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

java3

时间:2016-03-31 20:22:57      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:

class Address{
private String guojia;
private String shengfen;
private String chengshi;
private String jiedao;
private int youbian;
public Address(){

}
public Address(String guojia,String shengfen,String chengshi,String jiedao,int youbian){
this.setGuojia(guojia);
this.setShengfen(shengfen);
this.setChengshi(chengshi);
this.setJiedao(jiedao);
this.setYoubian(youbian);
}
public void setGuojia(String g){
guojia=g;
}
public void setShengfen(String s){
shengfen=s;
}
public void setChengshi(String c){
chengshi=c;
}
public void setJiedao(String j){
jiedao=j;
}
public void setYoubian(int y){
youbian=y;
}
public String getGuojia(){
return guojia;
}
public String getShengfen(){
return shengfen;
}
public String getChengshi(){
return chengshi;
}
public String getJiedao(){
return jiedao;
}
public int getYoubian(){
return youbian;
}
}
public class dizhi {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Address stu=null;
stu=new Address("中国","北京","北京","牛栏山",030032);
System.out.println("国家:"+stu.getGuojia());
System.out.println("省份:"+stu.getShengfen());
System.out.println("城市:"+stu.getChengshi());
System.out.println("街道:"+stu.getJiedao());
System.out.println("邮编:"+stu.getYoubian());
}

}

技术分享

class Employee{
private String bianhao;
private String xingming;
private float jixin;
public Employee(){

}
public Employee(String bianhao,String xingming,float jixin){
this.setBianhao(bianhao);
this.setXingming(xingming);
this.setJixin(jixin);
}
public void setBianhao(String b){
bianhao=b;
}
public void setXingming(String x){
xingming=x;
}
public void setJixin(float j){
jixin=j;
}
public String getBianhao(){
return bianhao;
}
public String getXingming(){
return xingming;
}
public float getJixin(){
return jixin;
}
public float getZengxin(){
return jixin*0.2f;
}
public float getZong(){
return jixin+getZengxin();
}
}
public class gongzi {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Employee stu=null;
stu=new Employee("M-A","张三",2000f );
System.out.println("编号:"+stu.getBianhao());
System.out.println("姓名:"+stu.getXingming());
System.out.println("基本薪水:"+stu.getJixin());
System.out.println("薪水增长额:"+stu.getZengxin());
System.out.println("工资总额:"+stu.getZong());
}

}

技术分享

class Dog{
private String name;
private String color;
private int old;
public Dog(){

}
public Dog(String name,String color,int old){
this.setName(name);
this.setColor(color);
this.setOld(old);
}
public void setName(String n){
name=n;
}
public void setColor(String c){
color=c;
}
public void setOld(int o){
old=o;
}
public String getName(){
return name;
}
public String getColor(){
return color;
}
public int getOld(){
return old;
}
}
public class xinxi{

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Dog stu=null;
stu=new Dog("李四","红",20);
System.out.println("姓名:"+stu.getName());
System.out.println("颜色:"+stu.getColor());
System.out.println("年龄:"+stu.getOld());
}

}

技术分享

class User{
private String name;
private String kouling;
private int gs;
public User(){
}
public User(String name,String kouling,int gs){
this.setName(name);
this.setKouling(kouling);
this.setGs(gs);
}
public void setName(String n){
name=n;
}
public void setKouling(String k){
kouling=k;
}

public void setGs(int g){
gs=g;
}
public String getName(){
return name;
}
public String getKouling(){
return kouling;
}
public int getGs(){

return gs;
}
}
public class yonghu {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
User stu=null;
stu=new User("张三","zhangsan",1);
System.out.println("用户名:"+stu.getName());
System.out.println("口令:"+stu.getKouling());
System.out.println("用户个数:"+stu.getGs());

}

}

技术分享

java3

标签:

原文地址:http://www.cnblogs.com/zp742601689/p/5342422.html

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