Getting Started with Java Lesson 60-- inherited Homework

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/houjunkang363/article/details/90632625

1. Identify the following compilation error codes, and why

    //哺乳动物
    public class Mammals{
    
    }
    //鸟类
    public class Birds{
    
    }
    //蝙蝠
    public class Bat extends Mammals,Birds{
    
    }

2. Say the output of the following code, and explain why

 public class Sub extends Base{
        String color;
        
        public Sub(double size,String name,String color){
            super(size,name);
            this.color=color;
        }
        
        public static void main(String[] args){
            Sub s=new Sub(5.6,"测试对象","红色");
            System.out.println(s.size+"--"+s.name+"--"+s.color);
        }
    }
    
    class Base{
        double size;
        String name;
        
        public Base(double size,String name){
            this.size=size;
            this.name=name;
        }
    }

3. say the output of the following code, and explain why

 //鸵鸟
    public class Ostrich extends Bird{
        public void fly(){
            System.out.println("我只能在地上奔跑...");
        }
        public static void main(String[] args){
            Ostrich os=new Ostrich();
            os.fly();
        }
    }
    class Bird{
        public void fly(){
            System.out.println("我在天空里自由自在的飞翔...");
        }
    }

4. say the output of the following code, and explain why

 public class SlowPoint extends Point{
        public void move(int dx,int dy){
            System.out.println("SlowPoint move parameter");
            move();
        }
        public static void main(String[] args){
            SlowPoint sp=new SlowPoint();
            sp.move(10,20);
        }
    }
    class Point{
        public void move(int dx,int dy){
            System.out.println("Point move parameter");
        }
        public void move(){
            System.out.println("Point move");
        }
    }

5. Complete TetrominoGame

    In class base case "Java method Rewrite Rules" on the realization of the whereabouts of the console version of the T-box, left and right, console input results are as follows:

    ---------打印T型---------
    i am a T
    (0,4),(0,5),(0,6),(1,5)
    - - - - * * * - - -
    - - - - - * - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    1——下落,2——向左,3——向右,0——退出
    1
    - - - - - - - - - -
    - - - - * * * - - -
    - - - - - * - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    1——下落,2——向左,3——向右,0——退出
    2
    - - - - - - - - - -
    - - - * * * - - - -
    - - - - * - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    1——下落,2——向左,3——向右,0——退出
    3
    - - - - - - - - - -
    - - - - * * * - - -
    - - - - - * - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - -
    1——下落,2——向左,3——向右,0——退出
    0

    When the user selects one, represents the drop function is selected; when the user selects 2, moved to the left indicating the selection function; 3 is selected when the user indicates that the user selected the function moves to the right; 0 indicates when the user selects the user selects Quit Features.

Scan code concern me:

Guess you like

Origin blog.csdn.net/houjunkang363/article/details/90632625