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

140201133-李宇昕-No.3

时间:2016-03-20 23:50:25      阅读:277      评论:0      收藏:0      [点我收藏+]

标签:

class Student {
 private String stuno;
 private String name;
 private float math;
 private float english;
 private float computer;
 public Student(){
  
 }
 public Student(String stuno,String name,float math,float english,float computer){
  this.setStuno(stuno);
  this.setName(name);
  this.setMath(math);
  this.setEnglish(english);
  this.setComputer(computer);
 }
 public void setStuno(String s){
  stuno=s;
 }
 public void setName(String n){
  name=n;
 }
 public void setMath(float m){
  math=m;
 }
 public void setEnglish(float e){
  english=e;
 }
 public void setComputer(float c){
  computer=c;
 }
 public String getStuno(){
  return stuno;
 }
 public String getName(){
  return name;
 }
 public float getMath(){
  return math;
 }
 public float getEnglish(){
  return english;
 }
 public float getComputer(){
  return computer;
 }
 public float sum(){
  return math+english+computer;
 }
 public float avg(){
  return this.sum()/3;
 }
 public float max(){
  float max=math;
  max=max>computer?max:computer;
  max=max>english?max:english;
  return max;
 }
 public float min(){
  float min=math;
  min=min<computer?min:computer;
  min=min<english?min:english;
  return min;
 }
}
public class ExampleDemo01 {

 /**
  * @param args
  */
 public static void main(String args[]) {
  Student stu=null;
  stu=new Student("MLDN-33","李兴华",95.0f,89.0f,96.0f);
  System.out.println("学生编号:"+stu.getStuno());
  System.out.println("学生姓名:"+stu.getName());
  System.out.println("数学成绩:"+stu.getMath());
  System.out.println("英语成绩:"+stu.getEnglish());
  System.out.println("计算机成绩:"+stu.getComputer());
  System.out.println("最高分:"+stu.max());
  System.out.println("最低分:"+stu.min());// TODO Auto-generated method stub

 }

}

技术分享

 

class Employee1 {
 private String empno;
 private String name;
 private float gongzi;
 private float zengzhange;
 private float zonge;
 public Employee1(){
 }
 public Employee1(String empno,String name,float gongzi){
  this.setEmpno(empno);
  this.setName(name);
  this.setGongzi(gongzi);
  this.setZengzhange(zengzhange);
  this.setZonge(zonge);
 }
 public void setEmpno(String e){
  empno=e;
 }
 public void setName(String n){
  name=n;
 }
 public void setGongzi(float g){
  gongzi=g;
 }
 public void setZengzhange(float z){
  z=gongzi*0.05f;
  zengzhange=z;
 }
 public void setZonge(float Z){
  Z=gongzi+zengzhange;
  zonge=Z;
 }
 public String getEmpno(){
  return empno;
 }
 public String getName(){
  return name;
 }
 public float getGongzi(){
  return gongzi;
 }
 public float getZengzhange(){
  return zengzhange;
 }
 public float getZonge(){
  return zonge;
 }
}
public class Employee {

 /**
  * @param args
  */
 public static void main(String args[]) {
  Employee1 emp=null;
  emp=new Employee1("1","李兴华",3000.5f);
  System.out.println("员工编号:"+emp.getEmpno());
  System.out.println("员工姓名:"+emp.getName());
  System.out.println("员工工资:"+emp.getGongzi());
  System.out.println("薪水增长额:"+emp.getZengzhange());
  System.out.println("总额:"+emp.getZonge());
  // TODO Auto-generated method stub

 }

}

class Dog1 {
 private String name;
 private String color;
 private String hobby;
 private int age;
 public Dog1(){
 }
 public Dog1(String name,String color,String hobby,int age){
  this.setName(name);
  this.setColor(color);
  this.setHobby(hobby);
  this.setAge(age);
 }
 public void setName(String n){
  name=n;
 }
 public void setColor(String c){
  color=c;
 }
 public void setHobby(String h){
  
  hobby=h;
 }
 public void setAge(int a){
  age=a;
 }
 public String getName(){
  return name;
 }
 public String getColor(){
  return color;
 }
 public String getHobby(){
  return hobby;
 }
 public int getAge(){
  return age;
 }
}
public class Dog {

 /**
  * @param args
  */
 public static void main(String args[]) {
  Dog1 dog=null;
  dog=new Dog1("小黑","黑色","乱叫",3);
  System.out.println("名字:"+dog.getName());
  System.out.println("颜色:"+dog.getColor());
  System.out.println("喜好:"+dog.getHobby());
  System.out.println("年龄:"+dog.getAge());
  // TODO Auto-generated method stub

 }

}

技术分享

 

class User1 {
 private String name;
 private int key;
 private int count;
 public User1(){
 }
 public User1(String name,int key,int count){
  this.setName(name);
  this.setKey(key);
  this.setCount(count);
 }
 public void setName(String n){
  name=n;
 }
 public void setKey(int k){
  key=k;
 }
 public void setCount(int c){
  count=c;
 }
 public String getName(){
  return name;
 }
 public int getKey(){
  return key;
 }
 public int getCount(){
  return count;
 }
}
public class User {

 /**
  * @param args
  */
 public static void main(String args[]) {
  User1 user=null;
  user=new User1("张",000000,1);
  System.out.println("用户名:"+user.getName());
  System.out.println("口令:"+user.getKey());
  System.out.println("用户个数:"+user.getCount());
  // TODO Auto-generated method stub

 }

}

技术分享

140201133-李宇昕-No.3

标签:

原文地址:http://www.cnblogs.com/lyxdbk/p/5300112.html

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