Assignment 2 inheritance and simple list structure



CS2230 – Assignment 2

This assignment will give you practice with the following:
 Class Inheritance practice
 Experience linked lists through Java’s ArrayList class
 Understanding how to define methods from verbal descriptions
Part 0: Additional Details
You will be practicing both inheritance and simple list structure through the ArrayList class. We will
discuss ArrayList in greater detail during class on Wednesday, September 7, 2016.
For this assignment you have been provided with two skeleton Netbeans projects. You will be expected
to complete these projects following the specifications below which are described. Each method will
include a short comment explaining the expected behavior of that method.
Part 1: Vehicle (15 pts)
You will be submitting the final Vehicle, Truck and Person classes with a test bed class.
Create a class called Vehicle that has the manufacturer’s name (type String), number of cylinders
in the engine (type int), and owner (type Person).
Then, create a class called Truck that is derived from Vehicle and has the following additional
properties: the load capacity in tons (type double since it may contain a fractional part) and towing
capacity in pounds (type int).
Be sure your class has a reasonable complement of constructors, accessor and mutator methods, and
suitably defined equals and toString methods. (See Person for an example equals method).
Write a program to test all your methods.
Part 2: Contacts (15 pts)
Write a program that uses an ArrayList of parameter type Contact to store a database of
contacts. The Contact class should store the contact’s first and last name, phone number, and email
address. Add appropriate accessor and mutator methods. Your database program should present a
menu that allows the user to add a contact, display all contacts, search for a specific contact and display
it, or search for a specific contact and give the user the option to delete it. The searches should find any
contact where any instance variable contains a target search string.
For example, if “elmore” is the search target, then any contact where the first name, last name, phone
number, or email address contains “elmore” should be returned for display or deletion. Use the “foreach” loop to iterate through the ArrayList.
Submitting Your Assignment
Due: September 12, 2016 at 11:59pm
The following source files should be submitted to the ICON dropbox inside a zip file containing the
package folders:
 package part1vehicle;
 package part2contact;


There are no reviews yet.

Be the first to review “Assignment 2 inheritance and simple list structure”

Your email address will not be published.