CSci 169 Programming HW 5a Java: Polymorphism solved

$24.99

Original Work ?

Download Details:

  • Name: HW5_a.zip
  • Type: zip
  • Size: 389.99 KB

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

Description

5/5 - (6 votes)

1. (10 points). You’ll write a function which takes as input an ArrayList of Strings and Integers, and
returns an ArrayList of objects from problem 2 of Programming HW 3 (to make it simpler, we’ll
restrict it to Food, Fruit, Apple, and Orange objects), and a sensible main that tests it. The starting
ArrayList should be formatted as follows: the name of the type of the next object, followed by
parameter(s) that should be sent as input to the class’ constructor (however if you should send a
Date as input, you will be given either the string “now” if you should use Date’s constructor that
takes no parameters, or an Integer if you should use the constructor that takes a long). So for
instance, the input ArrayList could contain the following: “Food”, “Orange”, “Fruit”, “Papaya”,
Integer(3932728), “Apple”, “now”, “Food”, “sandwich”, and the resulting ArrayList would have 5
objects in it, of type Food, Orange, Fruit, Apple, and Food.
You may wish to refer to the documentation for the Date class:
https://docs.oracle.com/javase/7/docs/api/java/util/Date.html
Note: Programming HW 5b will cover multiple inheritance and Interfaces, and will be due
Friday 5/10. This means multiple inheritance and Interfaces will NOT be on the midterm.
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 HW5 YourLastName YourIDNumber “