码迷,mamicode.com
首页 > 其他好文 > 详细

第三次作业

时间:2016-03-30 12:26:09      阅读:120      评论:0      收藏:0      [点我收藏+]

标签:

class Employee{
 int number;
 String name;
 int xinshui;
 int zengzhang;
 public void tell(){
  System.out.println("编号:"+number+",姓名:"+name+",薪水:"+xinshui+",增长:"+zengzhang+",工资:"+(zengzhang+xinshui));
 } 
}
public class dier{
 public static void main(String args[]){
  Employee per=new Employee();
  per.number=140201128;
  per.name="辽宁";
  per.xinshui=3000;
  per.zengzhang=1000;
  per.tell();
 }
}

 

 

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+",颜色:"+color+",年龄:"+age);
 }
 public String getName(){
  return name;
 }
 public void setName(String a){
  name=a;
 }
 public String getColor(){
  return color;
 }
 public void setColor(String b){
  color=b;
 }
 public int getAge(){
  return age;
 }
 public void setAge(int c){
  age=c;
 }
}
public class disi{
 public static void main(String args[]){
  Dog per=new Dog("大黄","黄",3);
  per.tell();
 }
}

 

 

class User{
 private String name;
 private String cdk;
 private int num;
 public User(){}
 public User(String name){
  this.setName(name);
 }
 public User(String name,String cdk){
  this.setName(name);
  this.setCdk(cdk);
 }
 public void tell(){
  System.out.println("名字:"+name+",口令:"+cdk+",个数:"+num);
 }
 public String getName(){
  return name;
 }
 public void setName(String a){
  name=a;
 }
 public String getCdk(){
  return cdk;
 }
 public void setCdk(String b){
  cdk=b;
 }
 public int getNum(){
  return num;
 }
 public void setNum(int c){
  num=c;
 }
}
public class diwu{
 public static void main(String args[]){
  User per=new User("LinXinHua","lxh",3);
  per.tell();
 }
}

 

class Address{
 String country;
 String shengfen;
 String city;
 String jiedao;
 int youbian;
 public void tell(){
  System.out.println("国家:"+country+",省份:"+shengfen+",城市:"+city+",街道:"+jiedao+",邮编:"+youbian);
 
}
public class diyi{
 public static void main(String args[]){
  Address per=new Address();
  per.country="中国";
  per.shengfen="辽宁";
  per.city="沈阳";
  per.jiedao="沈北新区";
  per.youbian=11300;
  per.tell();
 } 
}

 

第三次作业

标签:

原文地址:http://www.cnblogs.com/hao520-/p/5336470.html

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