第三次实训作业

package disici;

import java.util.*;

 

class mokey{

    private static String a;

    String s;

    public mokey(String s) {

        this.s=s;

    }

    public void speak()

     {

       System.out.println("咿咿呀呀");

     }

}

class people extends mokey{

 

    public people(String s) {

        super(s);

        }

    public void speak()

        {

            System.out.println("小样的,不错嘛!会说话了!");

        }

        public void think() {

            System.out.println("别说话!认真思考!");

        }

     

}

 

   

public class s {

 public static void main(String[] args) {

    String s;

    Scanner ex=new Scanner(System.in);

    s=ex.nextLine(); 

    mokey e1=new mokey(s);

    people e2=new people(s);

    e1.speak();

    e2.speak();

    e2.think();

     

    }

 

 

} 


  2.矩形







1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76 


package disici;

import java.util.*;

class juxing

{

    private String a;

    private String b;

    public juxing(String a) {

        this.a=a;

        this.b=b;

    }

    public void seta() {

        this.a=a;

    }

    public int geta(int a) {

        return a;

    }

    public void setb() {

        this.b=b;

    }

    public int getb(int b) {

        return b;

    }

    public int s(int a,int b) {

        return a*b;

    }

}

class changfangti{

    private String a;

    private String b;

    private String c;

    public void seta() {

        this.a=a;

    }

    public int geta(int a) {

        return a;

    }

    public void setb() {

        this.b=b;

    }

    public int getb(int b) {

        return b;

    }

    public void setc() {

        this.c=c;

    }

    public int getc(int c) {

        return c;

    }

    public static int v(int a,int b,int c) {

        return a*b*c;

    }

}

public class ee {

public static void main(String[]args) {

    Scanner ex=new Scanner(System.in);

    System.out.println("请输入长:");

    int a=ex.nextInt();

    ex.nextLine();

    System.out.println("请输入宽:");

    int b=ex.nextInt();

    ex.nextLine();

    System.out.println("请输入高:");

    int c=ex.nextInt();

    ex.nextLine();

    juxing e1=new juxing(null);

    changfangti e2=new changfangti();

    e1.geta(a);

    e1.geta(b);

    e2.geta(a);

    e2.getb(b);

    e2.getc(c);

    System.out.println("底面积:"+e1.s(a,b)+"体积:"+e2.v(a, b,c));

}

 

 

} 


  3.汽车







1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72 


package disici;

import java.util.*;

class vehicle{

    private String wheels;

    private String weight;

    public void setwheels() {

        this.wheels=wheels;

    }

    public int getwheels(int wheels) {

        return wheels;

    }

    public void setweight() {

        this.weight=weight;

    }

    public int getweight(int weight) {

        return weight;

    }

    public void measge(int wheels,int weight) {

        System.out.println("轮胎数:"+wheels+"重量:"+weight);

    }

}

class car extends vehicle {

    private String loader;

    public void setloader() {

        this.loader=loader;

    }

    public int getloader(int loader) {

        return loader;

    }

    public void measge(int loader) {

        System.out.println("载人数:"+loader);

    }

}

class  Truck extends car{

    private String payload;

    public void setpayload() {

        this.payload=payload;

    }

    public int getpayload(int payload) {

        return payload;

    }

    public void measge(int payload) {

        System.out.println("载重量:"+payload);

    }

}

public class qiche {

  public static void  main(String[]args) {

      Scanner ex=new Scanner(System.in);

      System.out.println("请输入轮胎数:");

      int wheels=ex.nextInt();

      ex.hasNextLine();

      System.out.println("请输入重量:");

      int weight=ex.nextInt();

      ex.hasNextLine();

      System.out.println("请输入载人数:");

      int loader=ex.nextInt();

      ex.hasNextLine();

      System.out.println("请输入载重:");

      int payload=ex.nextInt();

      ex.hasNextLine();

      vehicle e1=new vehicle();

      car e2=new car();

      Truck e3=new Truck();

      e1.getwheels(wheels);

      e1.getweight(weight);

      e2.getloader(loader);

      e3.getpayload(payload);

      e1.measge(wheels,weight);

      e2.measge(loader);

      e3.measge(payload);

  }

} 

 

posted on 2019-05-08 15:00  444555  阅读(699)  评论(0)    收藏  举报