Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Programming Language Expert

Develop a simple RentalCarCompany program for a Rental Car Company, call it whatever you like. We will have two classes, a Car class and aRentalCarCompany class. The RentalCarCompany class will contain several Car objects stored in an array and will have several operations. We will also have a tester class to test the RentalCarCompany class.

Specific Requirements for theCar class:

Default constructor that sets all instance variables to default values.

A parameterizes constructor that takes in parameters to set the class's instance variables : String (the name of the car renter), int (the car number: a number used to identify each rental car the company owns), String (the car name or model), String (the car type, for example, compact or mid size), double (the car's rental rate), and an int (the number of days rented).

Accessor and mutator methods for all the instance variables (see UML Class diagram above)

toString() returns the car renter's name, the car number, name, type, number of doors (2 or 4), car rental rate, and number of days rented. This should all be nicely formatted with one attribute on each line using the '\n' escape character (see sample output below for an example).

The UML class diagram for the Car class looks like this:

Car

carRenter: String

carNum: int

carName: String

carType: String

rate: double

days: int

Car()

Car(String,int,String,String,int, double,int)

getCarRenter(): String

getCarNum(): int

getCarName(): String

getCarType(): String

getCarRate(): double

getNumOfDays(): int

setCarRenter(String)

setCarNum(int)

setCarName(String)

setCarType(String)

setCarRate(double)

setNumOfDays(int)

toString: String

Specific Requirements for the RentalCarCompany class:

Default constructor

Parameterized constructor that takes in the name of the Car Rental Company.

Instance variables include an array of Car objects called theCars to hold information about each car. A String representing the name of the company and a variable called rentCnt the indicates how may cars have been rented (car object actually stored in the array).

A Class constant called NUM_CARS is an int representing the size of the array. For this project, we will assume that the rental car company will not have more than 20 cars, so set the array size to 20.

Methods

Accessor and mutator methods for name instance variable

addReservation method

Adds a Car object to theCars array using the parameters to create a Car object.

An array needs to be created with a fixed size, however number of cars rented at any time may vary therefore to solve this problem we will use a partially filled array (See text for details on partially filled arrays) . The instance field calledrentCnt indicates the actual number of cars currently rented.

getTotalRentalSales - returns a double representing the total sales of all the cars in the array, the sale value formula is the car's (rate * days)

findReservation

Searches the array using a parameter that reprsents a car's carNum.

If the reservation is found, the findReservation method will print out the rental car's information using the car's toStringmethod. If not, the method prints out a message indicating that the reservation was not found.

toString - will print out the information for each rental car by calling the toString method for each Car object. (see sample run below)

The UML class diagram for the RentalCarCompany class looks like this:

RentalCarCompany

theCars: Car[]

name: String

rentCnt : int

NUM_CARS: int

RentalCarCompany()

RentalCarCompany(String)

getName():String

setName(String)

addReservation(String, int, String, String, double, int)

getTotalRentalSales(): double

findReservation(int)

toString(): String

Build a RentalCarTest class to test your application. It should verify the correct operation of the constructor and all public methods in theRentalCarCompany class. Remember to test the addReservation() method, which should add cars to the array, and the findReservation()method, which should be able to find a car in the array of objects if it exists. See the sample output below for a sample run of the test program.

Your source files must have Javadoc comments for each class, method and constructor, with relevant tags.

You should turn in the following files for this assignment:

Car.java

RentalCarCompany.java

RentalCarTest.java

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M91376342
  • Price:- $50

Guranteed 36 Hours Delivery, In Price:- $50

Have any Question?


Related Questions in Programming Language

Question 1 what is hadoop explaining hadoop 2 what is

Question: 1. What is Hadoop (Explaining Hadoop) ? 2. What is HDFS? 3. What is YARN (Yet Another Resource Negotiator)? The response must be typed, single spaced, must be in times new roman font (size 12) and must follow t ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

1 write a function named check that has three parameters

1. Write a function named check () that has three parameters. The first parameter should accept an integer number, andthe second and third parameters should accept a double-precision number. The function body should just ...

Assignmentquestion onegiving the following code snippet

Assignment Question One Giving the following code snippet. What kind of errors you will get and how can you correct it. A. public class HelloJava { public static void main(String args[]) { int x=10; int y=2; System.out.p ...

Background informationthis assignment tests your

Background Information This assignment tests your understanding of and ability to apply the programming concepts we have covered throughout the unit. The concepts covered in the second half of the unit build upon the fun ...

Assignment task -q1 a the fibonacci numbers are the numbers

Assignment Task - Q1. (a) The Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and are characterised by the fact that every number after the first two is the sum of the ...

Question - create a microsoft word macro using vba visual

Question - Create a Microsoft Word macro using VBA (Visual Basic for Applications). Name the macro "highlight." The macro should highlight every third line of text in a document. (Imagine creating highlighting that will ...

Question 1 what is a computer program what is structured

Question: 1. What is a Computer program? What is structured programming? 2. What is modular programming? Why we use it? 3. Please evaluate Sin (x) by infinite series. Then write an algorithm to implement it with up to th ...

Assignment - proposal literature review research method1

Assignment - Proposal, Literature Review, Research Method 1. Abstract - Summary of the knowledge gap: problems of the existing research - Aim of the research, summary of what this project is to achieve - Summary of the a ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As