//属性和方法
private String name;
     private String sex;
     private int lovely;
     private int health;
     public String getName() {
         return name;
     }
     public void setName(String name) {
         this.name = name;
     }
     public String getSex() {
         return sex;
     }
     public void setSex(String sex) {
         this.sex = sex;
     }
     public int getLovely() {
         return lovely;
     }
     public void setLovely(int lovely) {
         if(lovely>=0&& lovely<=100){
             this.lovely = lovely;
         }else{
             this.lovely=60;
         }
              }
     public int getHealth() {
         return health;
     }
     public void setHealth(int health) {
         if(health>=0&& health<=100){
             this.health = health;
         }else{
             this.health=60;
         }
     }
     public void show(){
         System.out.println("我的名字是:"+this.name+"健康值是:"+health+
                 "亲密度是"+lovely+"我的性别是"+sex);
     }
//代码
    System.out.println("欢迎来到宠物系统");
     System.out.println("请输入想要领养的宠物的名字");
     Scanner sc=new Scanner(System.in);
     String name=sc.next();
     Penguin pen=new Penguin();    
     pen.setName(name);    
     System.out.println("请输入企鹅性别");
     int sex=sc.nextInt();
     if(sex==1){
         pen.setSex("Q妹");
     }else{
         pen.setSex("Q仔");
     }
     System.out.println("请输入企鹅的健康值(0-100之间)");
     int heal= sc.nextInt();
     pen.setHealth(heal);
     System.out.println("请输入企鹅的亲密度(0-100之间)");
     int lov= sc.nextInt();
     pen.setLovely(lov);
     pen.show();
 }
相关知识
宠物训练销售卡管理系统【宠物训练销售卡管理系统销售客户管理系统】
宠物管理系统是什么?
【宠物医院管理系统
SSM宠物领养管理系统
社区宠物诊所管理系统
基于SSM+Vue的宠物管理系统
宠物管理系统(宠物信息全面掌握)
RFID宠物溯源智能管理系统
python+vue+elementui宠物猫店管理系统
宠物行业OA办公系统、ERP管理系统
网址: 宠物管理系统 https://m.mcbbbk.com/newsview101926.html
| 上一篇: (微信小程序毕业设计)宠物寄养交 | 下一篇: 快速让你的宠物成为宠物王 |