PROG23199

Assignment #1

due date : Friday, February 9th/2016

For all assignments and labs, make sure your NAME + STUDENT ID appears in the console tab.

MAKE NOTE OF THE FOLLOWING REQUIREMENTS

Input VALIDATION (attribute values) should occur in the Constructor or maybe the setters.

Error handling or checking, should be in the main function.

PART I – Car Project

1) Rework the Car class developped in the previous lab (ie, having a make).

Add the following attributes :

a) a model (string data type)

b) year (this represents the year of manufacture, integer data type)

c) date (purchase date, use the String data type)

d) fuelAmount (the amount of fuel that car can hold in its storage tank, a double data type)

Most North-American vehicles have a maximum fuel amount capacity of 40 litres.

Some larger models have a larger fuel amount capacity of 60 litres.

Allow your program to accept the current amount of fuel available in the gas tank as the fuelAmount attribute. This attribute is different from the total gas tank maximum fuel amount capacity.

e) For cars that are older than 5 years (ie, older than 2010), print a message to the console advising the user : “Emission Test REQUIRED.” else print the following message : “Meeting standards !!!!”.

f) Add 2 methods to the Car class called : consumption and fillUp.

The fillUp method will allow the fuelAmount to increase by a “fillUpQuantity”.

The consumption method will allow the fuelAmount to decrease by a consumptionQuantity calculated as follows : “distanceTravelled” and “efficiencyIndex”. (consumptionQuantity = distanceTravelled * efficiencyIndex). Set the efficiencyIndex at 0.45.

Run your REVISED Car program with the following sample data :

i) Toyota, Prius, 2014, 2014-06-21, 20

ii) Ford, Escort, 2008, 2011-07-23, 40

iii) Fiat, 500, 2006, 2014-12-10, 60

iv) Volkswagen, Passat, 2015, 2015-02-03, 35

v) Ford, Escord, 1998, 1998-03-06, 23

As for the lab, allow your program to accept user input for each one of the parameters.

Make modification to your program to allow a user to input a “distance travelled” value.

Demonstrate using the standard input/output streams (keyboard/monitor).

Write the appropriate getters/setters following the Account model discussed in class.

PART II – Person Project

2) Create a class called “Person”. A “Person” object has a name and age attribute..

a) Add the following attributes :

i) height (double data type, represented as metres “m”)

ii) weight (double data type, represented as kilograms “kg”)

iii) main language (String data type)

iv) gendre (only 2 types allows : MALE or FEMALE. Keep the gendre as a String)

b) Add conditional logic based on the age of a person to print a console output as follows :

i) less than 18 years old (MINOR)

ii) more than 65 years old (SENIOR)

c) Add conditional logic as follows :

i) if the primary language is either FRENCH or ENGLISH print a message to the Console :

You might be Canadian !!!”.

ii) Limit the choice of languages to only : FRENCH, ENGLISH and SPANISH.

If another language is entered by the user, print the message to the console as :

Sorry, I do not recognize this language. Retry again later. Thank you !!!!”.

iii) If the eight of a person is more than 1m 80 (or 6ft), print a message to the console :

Wow. You are tall !!!”.

Run your JAVA Program using a Person class with the following SAMPLE DATA :

i) Alice, 21, 1m 66, 50kg, French, Female

ii) Bob, 67, 1m 57, 45kg, Spanish, Male

iii) Oliver, 17, 1m 84, 58kg, English, Male

iv) Ruhm, 37, 1m 72, 62kg, German, Male

v) Annette, 73, 1m 57, 48kg, English, Female

vi) Felix, 71, 1m 57, 67kg, French, Male

vii) Simona, 16, 1m 84, 53kg, Italian, Female

viii) Jennifer, 15, 1m 84, 47kg, Dutch, Female

As for the lab, allow your program to accept user input for each one of the parameters.

Write the appropriate getters/setters following the Account model discussed in class.

PART III – Shape Project

3) Rework the Shape class developped in the previous lab (ie, having a width and height).

a) Add the following attributes :

i) a fill Pattern (string data type)

ii) contour pattern (string data type)

iii) color (string pattern)

b) Add conditional logic in a 2 argument constructor taking the width and height as arguments to verify if the “width” and “height” are not zero and also verify if the “width” and “height” are not equal.

If the “width” and “height” are equal display the following message in a JOptionPane :

This is a SQUARE !!!!. I can only work with RECTANGLES !!!”.

c) A Shape class will have to methods called : “calculateArea” and “calculatePerimeter”.

Use the following formulas to calculate the Area and Perimeter:

Area = width * height

Perimeter = 2* (width * height)

As for the lab, allow your program to accept user input for each one of the parameters.

Demonstrate using the standard input/output streams (keyboard/monitor).

Write the appropriate getters/setters following the Account model discussed in class.