Develop a simple rentalcarcompany program for a rental car

Assignment Help Programming Languages
Reference no: EM13806363

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

Reference no: EM13806363

Questions Cloud

What is the approximate radius of a nucleus : What is the approximate radius of a nucleus - How many nuclei are present 1h and 49 min later?
Write an essay about the right of habeas corpus : Write an essay about the right of habeas corpus in the context of the war on terror. Your essay should address the following subtopics
Write an essay about islam : Write an essay about islam.
Global organization with a multinational presence : Identify a global organization with a multinational presence. Identify and research a cultural issue that affects this organization's interactions outside the United States.
Develop a simple rentalcarcompany program for a rental car : 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
How will we ensure an engaging relevant pedagogy : How will we ensure an engaging relevant pedagogy
How artistic culture in india exhibits from western cultures : discuss how the artistic culture in either India, China, or Japan (select one) exhibits influence from Western cultures.
What orientation of the coil allows : Is the incoming flux equal to the outgoing flux - Why is the outgoing peak higher than the incoming peak?
Explain the jit philosophy : Explain the JIT philosophy. Identify the customer expectations for the service and/or product.

Reviews

Write a Review

Programming Languages Questions & Answers

  Which functions perform assignment score to private member

Consider this class definition: class quiz { public: quiz( ); int f( ); int g( ) const; private: double score; }; Which functions can carry out an assignment score=1.0; to the private member variable score?

  Analysis the advantages and disadvantages of social network

Analyze how the university might integrate at least two social media and networking technologies to accomplish their goals. Your analysis must cover the advantages and disadvantages of social networking.

  Create program in pseudocode to compute amount of money

Create the program in pseudocode which computes the amount of money a person would earn over period of time if their salary is one penny first day.

  Develop a domain-specific language within ruby

Develop a domain-specific language within Ruby, such as for manipulating files in a directory system, editing files, generating quizzes, describing graphical or geographical scenes, and adding and viewing entries in a calendar.

  Web programming

Work through the project instructions using the provided base files. Please note the detailed grading rubric included in the instruction document

  Write a program to find a baseball players batting average

Write a program to find a baseball player's batting average. The program should ask the user to enter the number of times the player was at bat and the number of hits he got. It should then show his batting average to four decimal places.

  Problem 1 where on the implied uncertainty spectrum do the

problem 1 where on the implied uncertainty spectrum do the following products fall? fill the letters a b or c in three

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Executive committee for alleviating it complexity

You are a consultant brought in by the executive committee to make recommendations for alleviating the "IT complexity" concerns of the executives at the company.

  Activity for pdus on project management institute-s web site

Several activity categories are given as qualifying for PDUs on project Management Institute's Web site. Recognize  these categories. In which categories would you place Chris's experience?

  What are the disadvantages of using technology

Describe your reasons for choosing this virtualisation technology, what advantages does this virtualisation and technology give you in this scenario - What are the disadvantages of using this technology?

  Clear description of the program you are building

Your final project will be to analyze, design, and document a simple program that utilizes a good design process and incorporates sequential, selection and repetitive programming statements as well as function and subprogram calls and uses arrays...

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd