Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Step: 3

blur-text-image

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

Optimization And Data Science Trends And Applications 5th Airoyoung Workshop And Airo Phd School 2021 Joint Event

Authors: Adriano Masone ,Veronica Dal Sasso ,Valentina Morandi

1st Edition

3030862887, 978-3030862886

More Books

Students also viewed these Databases questions

Question

Discuss five types of employee training.

Answered: 1 week ago