CSci 169 Programming HW 5b Java: Multiple Inheritance, Interfaces solved

$24.99

Original Work ?

Download Details:

  • Name: HW5_b-3.zip
  • Type: zip
  • Size: 377.51 KB

Category: You will Instantly receive a download link upon Payment||Click Original Work Button for Custom work

Description

5/5 - (2 votes)

1. (7 points). In this problem, you’ll be working with the Food, Fruit, Apple, and Orange classes from
problem 2 of Programming HW 3. You should modify your Fruit class so that it implements Java’s
Comparable interface: https://www.javatpoint.com/Comparable-interface-in-collection-framework
A piece of fruit should be considered greater if its ripe Date is later.
You should also create a main function and/or class that creates an ArrayList of Fruit, prints out its
contents in a nice format, sorts it, and prints out its contents again.
You may wish to refer to the documentation for the Date class:
https://docs.oracle.com/javase/7/docs/api/java/util/Date.html
2. (8 points) In this problem, you’ll be working with the Food, Fruit, Apple, and Orange classes from
problem 2 of Programming HW 3. Translate these classes into C++, and add the following two
classes:
Vegetable, which inherits from Food (Data: expiration:Date, Methods: Vegetable(),
Vegetable(n:String, e:Date), expireTime():Date)
Tomato, which inherits from Vegetable and Fruit (Data: None, Methods: Tomato(),
Tomato(e:Date, r:Date, n:String))
Add print statements to all constructors that show which class’s constructor has been called.
You should ensure that the Food constructor is called only once when a Tomato object is
created.
Also include a main function that creates a Tomato object and calls all of its member functions.
Submission instructions: You will print out your code for each problem, stapling together
multiple sheets (there will be deductions for unstapled homework!). Turn in the hardcopy at the
beginning of class. You will ALSO submit all of your .java files as attachments, to
cs169@math.scu.edu (NOT Dr. Linnell’s email!!)
The subject line of the email should be “CS169 HW5b YourLastName YourIDNumber “