Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Thanks for help my java question! I will upvote when you done. Part I: Inheritance Here is a UML hierarchy of Fruits. Your first step

Thanks for help my java question! I will upvote when you done. image text in transcribedimage text in transcribed

Part I: Inheritance Here is a UML hierarchy of Fruits. Your first step is to implement this hierarchy. In constructors with args, you should use super() constructor with args to set the values in superclasses. toString() should contain the name of the class and all of the fields/data for that class. You can decide whether this will work by a subclass calling the toString method of the superclass and including that in the subclass toString result (as in the GeometricObject hierarchy) or if the toString method accesses all the data/fields in the object itself. Fruit -color:String -rotten:Boolean -next id:int id:int +Fruit() +Fruit(color:String, rotten:boolean) +getColor():String +setColor(color:String): void +isRotten():boolean +setRotten (rotten:boolean):void +getld():int +toString():String extends Citris extends -taste: String +Citrus() + Citrus(taste:String, color:String, rotten:boolean) +getTaste():String +setTaste(taste:String): void +toString():String Apple extends extends Orange -taste:String -texture:String +Apple() +Apple(taste:String, texture:String, color:String, rotten:boolean) +getTaste():String +setTaste(taste:String): void +getTexture(): String + setTexture(texture:String): void +toString():String -type:String +Orange() + Orange(type:String, taste:String, rotten:Boolean) +getType():String +setType(type:String): void +toString():String Lemon -sourness:int +Lemon() +Lemon(sourness:int,taste:String rotten:boolean) +getSourness():int +setSourness(sourness:int): void +toString():String | Orange objects are always "orange" in color. Lemon objects are always "yellow" in color. This uses the static "id" pattern. Every creation of a new Fruit object (of any kind) should generate a new and unique id from the static next_id field, which is stored in the id field and accessible by getId Now that you've implemented this, write equals methods for all the classes. The equals method should take an Object as an argument and return true if the field values of the class and its superclass(es) are equal. Inheritance.java X 1 package fruit; 2 3 public class Inheritance { 4. 50 public static void main(String[] args) { 6 // Here's some scratch space to experiment/debug your Fruit objects 7 8 } 9 10 } 11

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions

Question

4. What did you learn from this role-play?

Answered: 1 week ago

Question

please try to give correct answer 3 .

Answered: 1 week ago