Question: Apple Class Review: http://www.prevention.com/food/apple-varieties-and-recipes/slide/10 Write a class Apple.java, this class should be separate, but in the same project as your test class AppleTest.java. AppleTest.java should

Apple Class

Review: http://www.prevention.com/food/apple-varieties-and-recipes/slide/10

Write a class Apple.java, this class should be separate, but in the same project as your test class AppleTest.java.

AppleTest.java should have your public static void main method and also complete the requirements noted below

under Test Class

All skills used in this program are in Chapter 9: Objects and Classes, and Chapter 10: Object-Oriented Thinking and

do not forget to use an Array of Objects.

Constructors:

- Blank constructor () that defaults the apple to empty values for name and love story and zero for established.

Two parameter constructor (String name, int established) that sets the name and established value (established

cannot be negative), and sets love story to empty.

- Three parameter constructor (String name, int established, String lovestory) that sets all three attributes.

- ** ensure that the established date is valid if you are setting it within the constructor, if its not valid (e.g. negative or

before year 1700, choose a default established date)

Private Attributes:

- name

- established

- love story

Public Methods:

- Getter/Setter for all attributes (properly named)

- In the established setter method ** ensure that the established date is valid if you are setting it within theconstructor,

if its not valid (e.g. negative or before year 1700, choose a default established date)

- print() or toString() that prints a string version of the apple (name, established and love story)

Test Class

- Instantiate 5 apples using each of the constructors at least once, then using appropriate setter to set attributes

that were not set via the constructor.

- Create an Apple Array [5], then Populate the array with the 5 apples

- Write a separate method to print the array of apples

- Sort the apples by established date before printing

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!