Computer Science II
Objectives: The two main objectives of this project are to test your ability to (1) create and use pointers, and (2) create and use C++ classes. A review of your knowledge of structs, arrays, iostream, file I/O and C-style strings is also included.
This project will expand Project 2 by adding additional functionality and implementing abstract data types (ADTs) through classes. The new functionality is as follows: You are given an updated data file (e.g. Agencies.txt) where there are 3 rental Car Agency locations, where each of the 3 locations (RentalAgency) has 5 cars (RentalCar). You will have similar menu options, but the functionality has been updated below. Note: using multiple helper functions to do smaller tasks will make this project significantly easier. You may want to create a function that will get a car from a location based on the location and car indices.
The RentalCar Class will contain the following private data members:
year, an int (year of production)
make, a C-string (char array of 256 maximum size)
model, a C-string (char array of 256 maximum size)
price, a float (price per day)
available, a bool (1 = true; 0 = false; try to display true/false using the "std::boolalpha" manipulator like: cout << boolalpha << boolVariable; )
and will have the following public methods:
Default Constructor – will set the aforementioned data members to default initial values of your selection, and m_available specifically to false. (Hint: Remember to use properly named constants where appropriate).
Parameterized Constructor – will create a new object based on the values of the arguments passed into In its parameters list: a) there should be a parameter corresponding to every one of the class data members, b) there should also be a default parameter for the parameter used to specify whether the car is available.
Separate get and set methods for all data
print – will print out all the car’s
estimateCost – will estimate the car’s cost given (via a parameter passed to it) a number of days to rent it
The RentalAgency ADT will be a struct and will contain the following data members:
name, a C-string (char array of 256 maximum size)
zipcode, an int array of size 5 (Hint: You will NOT be able to use cin and cout –or any fstream objects– directly with this int array as you were doing so far with C- strings. The reason is that reading/writing is specially handled by C++ for char array types. You will need to manage reading/writing to an int array on your )
inventory, an array of RentalCar objects with a size of 5
The menu must have the following entries, each implementing a functionality:
Ask the user for the input file name. Then, read ALL data from that file (the file has been structured where the first line is the Car Agency info, followed by 5 cars). The data have to be stored into arrays of Class type Objects.
Print out to terminal ALL data for all Agencies and all their corresponding Cars in a way that demonstrates this relationship (see Sample Output section).
Estimate car rental cost - prompt for: a) an Agency (e.g., Hertz – you can do so with a 0-2 int array index number per-Agency), b) a Car number (with a 0-4 int array index number per-Car of each agency), c) the number of days to rent it for (rental_cost=days_to_rent*price_per_day).
Find the most expensive Car – Print to terminal the single most expensive Car out of all 3
Print out only the available Cars - from all Agencies, to a separate output file (when the user chooses menu entry 5, they should also get asked for an output file name).
The following minimum functionality and structure is required:
Ask the user for the input file
The list(s) of cars must be stored into array(s) of Class type Objects.
The list of agencies must be stored into an array of Struct Objects.
Use character arrays to hold your strings (i.e., C-strings) exclusively (using the
std::string data type is still not allowed).
Write multiple functions (Hint: You could have each menu option be a function).
The other functionality and structure of the program should remain the same as Project #2, including writing to screen and file, as well as restrictions on string libraries, global variables and constants, etc.
Implement the concepts of encapsulation and data hiding!
Making the RentalCar data members private and implementing a public interface through the class Constructors and other methods is your first acquaintance with these concepts in practice.
Try to structure your class source code to implement the concepts of encapsulation and data hiding!
Try to structure your declarations and implementaions as much as possible into class/struct header files (e.g. RentalCar.h, RentalAgency.h), class/struct source files (e.g. RentalCar.cpp, RentalAgency.cpp), and other source files (proj3.cpp).
Do your best in order to acquaint yourself with these new concepts at this early point, so that it pays off in future project which will impose such hard requirements.
Sample Output for menu option 2:
2014 Toyota Tacoma , $115.12 per day , Available: true 2012 Honda CRV , $85.1 per day , Available: false 2015 Ford Fusion , $90.89 per day , Available: false 2013 GMC Yukon , $110.43 per day , Available: false 2009 Dodge Neon , $45.25 per day , Available: true
2011 Toyota Rav4 , $65.02 per day , Available: true 2012 Mazda CX5 , $86.75 per day , Available: true 2016 Subaru Outback , $71.27 per day , Available: false 2015 Ford F150 , $112.83 per day , Available: true 2010 Toyota Corolla , $50.36 per day , Available: true
2008 Ford Fiesta , $42.48 per day , Available: false 2009 Dodge Charger , $55.36 per day , Available: true 2012 Chevy Volt , $89.03 per day , Available: false 2007 Subaru Legacy , $59.19 per day , Available: false 2010 Nissan Maxima , $51.68 per day , Available: true
The completed project should have the following properties:
Written, compiled and tested using
It must compile successfully using the g++ compiler on department machines. Instructions how to remotely connect to department machines are included in the Projects folder in WebCampus.
The code must be commented and indented properly. Header comments are required on all files and recommended for the rest of the program. Descriptions of functions commented properly.
A one page (minimum) typed sheet documenting your code. This should include the overall purpose of the program, your design, problems (if any), and any changes you would make given more time.
The ready solutions purchased from Library are already used solutions. Please do not submit them directly as it may lead to plagiarism. Once paid, the solution file download link will be sent to your provided email. Please either use them for learning purpose or re-write them in your own language. In case if you haven't get the email, do let us know via chat support.
Get Free Quote!
261 Experts Online