为了账号安全,请及时绑定邮箱和手机立即绑定

错在哪里打到public goid print(){}就错了

package eletricpet;


public class dog {

    private String name = "无名氏";

    private int health = 100;

    private int love = 0;

    private String strain = "聪明的拉布拉多";

    

    //给名字赋值

    public void setName(String name){

    this.name=name;

    }

    //取name值

    public String getName(){

    return this.name;  

    }

    //health

    public void setHealth(int health){

    if(health<=0 || health>100){

    System.out.println("健康有误");

    this.health=60;

    }else

    this.health=health;

    }

    //love

    public void setLove(int love){

    if(love<=0 || love>100){

    System.out.println("亲密度有误");

    this.love=3;

    }else

    this.love=health;

    //品种

     public void print(){

     

     }


正在回答

3 回答

package com.huawei.xuexi;


import java.net.MalformedURLException;

import java.net.URL;


//关于url的常用方法

public class Test02 {

   private String name = "无名氏";

   private int health = 100;

   private int love = 0;

   private String strain = "聪明的拉布拉多";

   

   //给名字赋值

   public void setName(String name){

   this.name=name;

   }

   //取name值

   public String getName(){

   return this.name;  

   }

   //health

   public void setHealth(int health){

   if(health<=0 || health>100){

   System.out.println("健康有误");

   this.health=60;

   }else

   this.health=health;

   }

   //love

   public void setLove(int love){

   if(love<=0 || love>100){

   System.out.println("亲密度有误");

   this.love=3;

   }else

   this.love=health;

   }

   //品种

    public void print(){

    

    }

}


0 回复 有任何疑惑可以回复我~

少两个大括号,this.love=health;这行下面少一个,最后少一个。

0 回复 有任何疑惑可以回复我~

  //love

    public void setLove(int love){

    if(love<=0 || love>100){

    System.out.println("亲密度有误");

    this.love=3;

    }else

    this.love=health;

这个方法是不是少一个大括号?

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
Java入门第二季 升级版
  • 参与学习       530833    人
  • 解答问题       6091    个

课程升级!以终为始告别枯燥,在开发和重构中体会Java面向对象编程的奥妙

进入课程

错在哪里打到public goid print(){}就错了

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号