菜鸟的博客

纵有疾风起,人生不言弃。

导航

人生若只如初见~

好久没写简单的代码了~唉~

import java.util.Scanner;

public class Main {
    public  static void main(String[] args){
        Man man = new Man();
        Woman woman = new Woman();
        Robot robot = new Robot();

        Scanner  scanner = new Scanner(System.in);
        String flag = scanner.next();

        if(flag.equals("M")){
            man.MakePerson();
        } else if (flag.equals("W")) {
            woman.MakePerson();
        }else{
            robot.MakePerson();
        }

    }
}
public interface Nvwa {

    //这里呢可以先定义一个接口
    void   MakePerson();
}
public class Man implements Nvwa{
    @Override
    public void MakePerson() {
        System.out.println("女娲造Man!");
    }
}
public class Woman implements Nvwa{

    @Override
    public void MakePerson() {
        System.out.println("女娲造Woman!");
    }
}
public class Robot implements Nvwa{

    @Override
    public void MakePerson() {
        System.out.println("女娲造Robot!");
    }
}

 

posted on 2024-10-23 19:05  hhmzd233  阅读(8)  评论(0编辑  收藏  举报