老师给点意见

老师给点意见

package jicheng.one1;
 
public class four1 {
private String shape;
private String taste;
public four1() {}
public four1(String shape,String taste) {
	this.setShape(shape);
	this.setTaste(taste);
}
public void setShape(String shape) {
	this.shape=shape;
}
public String getShape() {
	return this.shape;
}
public void setTaste(String taste) {
	this.taste=taste;
}
public String getTaste() {
	return this.taste;
}
public void eat() {
	System.out.println("水果可供人们使用");
}
public boolean equals(Object obj) {
	if(obj==null)
	  return false;
	 four1 scc=(four1)obj;
if(this.getShape().equals(scc.getShape())&&this.getTaste().equals(scc.getTaste()))
		return true;
          else
        	  return  false;
}
public boolean equals(four1 obj) {
if(obj==null)
	return false	;
if(this.getShape().equals(obj.getShape())&&this.getTaste().equals(obj.getTaste()))
	return true;
else	
	return false;
}
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
package jicheng.one1;

public final class  four2 extends four1 {
	private String color;
	 public four2() {}
	 public four2(String color,String shape,String taste) {
		 this.setColor(color);
		 this.setShape(shape);
		 this.setTaste(taste);
	 }
       public void setColor(String color) {
    	   this.color=color;
       }
   public String getColor() {
	  return color;
   }
   public final void face() {
	   System.out.println("杨梅"+this.getColor()+this.getShape()+this.getTaste());
   }
   public void eat() {
	   System.out.println("杨酸梅甜适中,非常好吃");
   }
   public String toString() {
	   return this.getShape()+"  "+this.getColor()+"  "+this.getTaste();
	   }
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
package jicheng.one1;

public class four3 extends four1 {
private String variety;
public four3() {}
public four3(String variety,String shape) {
	this.setVariety(variety);
	super.setShape(shape);
}
public void setVariety(String variety) {
	this.variety=variety;
	}
public String getVariety() {
	return variety;
}
public void advantage() {
	System.out.println(this.getVariety()+"果型"+this.getShape()+",果肉香甜,可供食");
}
public void advantage(String color) {
	System.out.println(this.getVariety()+"颜色为"+color);
}
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
package jicheng.one2;
import jicheng.one1.*;
public class Ce4 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
    four1 one=new four1("圆形","果味酸甜");
    four1 two=new four1("圆形","果味酸甜");
		one.eat();
		System.out.println("one与two比较"+one.equals(two));
		System.out.println("________________________________________________________________________");
		four2 sc1=new  four2("紫红色","圆形","果味酸甜适中");
		sc1.face();
		sc1.eat();
		System.out.println(sc1);
		System.out.println(sc1.toString());
		System.out.println("________________________________________________________________________");
		four3 sc2=new four3("仙人蕉","短而稍园");
		sc2.advantage();
		sc2.advantage("黄色");
	}

}


正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

1回答
好帮手慕小尤 2022-09-05 14:45:38

同学你好,1、测试同学代码同学已完成练习。

2、同学命名有一些问题,

    1)当类名由一个单词组成时,该单词首字母大写;如果类名由多个单词组成,则每个单词的首字母均大写。

    2)类名建议见名知意。如下所示:

https://img1.sycdn.imooc.com//climg/63159a7e0973c55804550049.jpg

祝学习愉快!

问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师