Design an abstract class named Fruit that has the following fields:
nameOfFruit for storing a fruit’s name
fruitsCountry fruit’s origin country.
In addition, the class should have the following constructor and other methods:
Constructor with arguments to initialize both data fields.
A toString method to return a String containing the fruit’s data.
An abstract method named color() for fruit’s color and hold a void type.
An abstract method getInterExport() that hold an int type.
Then, design a class named Apple which extends the Fruit class. It declares three final integer fields with their values as: FUJI = 2000, GALA = 4500 and CAMEO = 3000.
These fields hold the total apples according to it types. The class also declares three integer fields to indicate the apples that have been allocated for local distribution. Declares the three fields as, localFuji, localGala and localCameo.
Next, provide the Apple constructor by calling the constructor of the superclass (Fruit) through the super keyword. After that, provide the mutator (set) methods to store values in localFuji, localGala and localCameo fields. Finally, Apple class will override:
o Abstract color() method defined in Fruit class. In this method, print the color of apple fruits as red sport, ultra red and red in one line.
o Abstract getInterExport() method defined in Fruit class. In this method, declare two integer variables called totalApple and totalExport. totalApple hold the total amount of apples and totalExport hold total apples to be exported after deduction with apples for local distribution. To calculate the totalApple, add all final integer fields. To calculate the totalExport, deduct totalApple with localFuji, localGala and localCameo. Return the totalExport.
o A toString method defined in Fruit class and also displays Fuji, Gala and Cameo apple for local distribution.
Provide ExportAppleDemo class to demonstrate the Fruit and Apple classes. Example of the program output is given:
Output:
Name of fruit: Apple New Varieties
Origin Country: New Zealand
Fuji apple for local distribution = 1200
Gala apple for local distribution = 900
Cameo apple for local distribution = 1500
Apples color: red sport, ultra red and red
Apples for international distribution: 5900
Hello,
I've been using Java for more 5+ years,
I can make your project in no time,
I've already done a lot similar projects before,
Feel free to ask me anything,
Thank you,
Oualid H.
Hello. I'm knowledgeable about Java, and I'm confident that I can deliver this project to you in a brief amount of time. Let's chat so that we may reach an agreement.
Hi,
I am a developer and designer with 5+ years of experience in C#, Excel, VBA, HTML, Css and javascript
I am new to this freelancer platform but I can guarantee my work.
Let's connect on chat for detail discussion.
Looking forward to working with you.
Thanks and Regards,
Bhoomi