| 
 
| //学生类的标准型: class StudentTest1 {
 public static void main(String[] args) {
 Student s = new Student();
 s.setName("抬头看看");
 s.setAge(20);
 s.setGender("男");
 System.out.println( s.getName() + "..." + s.getAge() + s.getGender() );
 s.study();
 s.sleep();
 }
 }//StudentTest1类
 
 class Student {
 private String name;
 private int age;
 private String gender;
 
 public void setName(String name) {
 this.name = name;
 }
 
 public String getName() {
 return name;
 }
 
 public void setAge(int age) {
 this.age = age;
 }
 
 public int getAge() {
 return age;
 }
 
 public void setGender(String gender) {
 this.gender = gender;
 }
 
 public String getGender() {
 return gender;
 }
 
 public void study() {
 System.out.println("学习");
 }
 
 public void sleep() {
 System.out.println("睡觉");
 }
 
 }
 //手机的标准类
 class PhoneTest1 {
 public static void main(String[] args) {
 Phone p = new Phone();
 p.setBrand("苹果");
 p.setPrice(5000);
 System.out.println( p.getBrand() + ":" + p.getPrice() );
 p.call();
 p.sendMessage();
 p.playGame();
 }
 }//PhoneTest1类
 
 class Phone {
 private String brand;
 private int price;
 
 public void setBrand(String brand) {
 this.brand = brand;
 }
 
 public String getBrand() {
 return brand;
 }
 
 public void setPrice(int price) {
 this.price = price;
 }
 
 public int getPrice() {
 return price;
 }
 
 public void call() {
 System.out.println("打电话");
 }
 
 public void sendMessage() {
 System.out.println("手机可以发短信");
 }
 
 public void playGame() {
 System.out.println("玩游戏");
 }
 }
 
 //汽车类的标准型:
 class CarTest1 {
 public static void main(String[] args) {
 Car c = new Car();
 c.setColor("丰田");
 c.setNum(4);
 System.out.println( c.getColor() + "..." + c.getNum() );
 c.run();
 }
 }//CarTest1类
 
 class Car {
 private String color;
 private int num;
 
 public void setColor(String color) {
 this.color = color;
 }
 
 public String getColor() {
 return color;
 }
 
 public void setNum(int num) {
 this.num = num;
 }
 
 public int getNum() {
 return num;
 }
 
 public void run() {
 System.out.println("车会跑");
 }
 }
 
 //员工类的标准形式
 class Employee {
 public static void main(String[] args) {
 Staff s = new Staff();
 s.setName("张三");
 s.setId("112233");
 s.setSalary(10000);
 System.out.println( s.getName() + "..." + s.getId() + "..." + s.getSalary() );
 s.work();
 s.eat();
 }
 }//StaffTest类
 
 class Staff {
 private String name;
 private String id;
 private int salary;
 
 public void setName(String name) {
 this.name = name;
 }
 
 public String getName() {
 return name;
 }
 
 public void setId(String id) {
 this.id = id;
 }
 
 public String getId() {
 return id;
 }
 
 public void setSalary(int salary) {
 this.salary = salary;
 }
 
 public int getSalary() {
 return salary;
 }
 
 public void work() {
 System.out.println( name + "..." + id + "..." + salary );
 }
 
 public void eat() {
 System.out.println("吃饭");
 }
 
 }
 | 
 |