- import java.util.Scanner;
- class Human { //人类
- private String name;
- private int age;
- private String cha;
- public String think;
- public void getThink(String think) //思考方法
- {
- this.think=think;
- }
- public void setName(String name,int age,String cha) //构造方法 构造姓名 年龄 性别
- {
- this.name = name;
- this.age=age;
- this.cha=cha;
- }
- public String getName(String name){ //转换为保护数据
- return this.name;
- }
- public int getAge(int age){
- return this.age;
- }
- }
- class Pupil extends Human { //学生类
- public String style;
- private String number;
- public void getstyle(String style) //学习方法
- {
- this.style=style;
- }
- public void setstyle(String style) //构造方法
- {
- this.style = style;
- }
- public String getnumber() //获取学号
- {
- return this.number;
- }
- public void number(String number) //转化为受保护数据
- {
- this.number = number;
- }
- }
- class Student extends Pupil //大学生类
- {
- public String style1;
- public void setstyle1(String style1) //构造方法
- {
- this.style1 = style1;
- }
- public void getstyle1(String style) //学习方法
- {
- this.style1=style;
- }
- void printf(String name,int age,String cha,String number,String style) //打印方法
- {
- System.out.printf("%s %d %s %s %s\n",name,age,cha,number,style);
- }
- }
- class example //主入口类 列举例子
- {
- String s1="zhang",s2="liubu",s3="kojlih";
- int a1=18,a2=19,a3=20;
- String c1="man",c2="women",c3="man";
- String n1="1804010328",n2="1804010119",n3="1802039087";
- String h1="reading",h2="listening",h3="running";
- }
- public class Main {
- public static void main(String[] args) {
- Scanner AI=new Scanner(System.in);
- Human HH=new Human();
- Pupil PP=new Pupil();
- Student SS=new Student();
- example EE=new example();
- SS.printf(EE.s1, EE.a1, EE.c1, EE.n1, EE.h1);
- SS.printf(EE.s2, EE.a2, EE.c2, EE.n2, EE.h2);
- SS.printf(EE.s3, EE.a3, EE.c3, EE.n3, EE.h3);
- }
- }