
” 写作COP3503程序、 辅导C++程序语言、 写作C++课程程序Programming Fundamentals 2University of FloridaLab 2 ClassesOverviewThe purpose of this assignment is give you some experience writing classes in C++, the various specialfunctions they make use of (such as copy constructors, assignment operators, and destructors), as wellas an introduction to dynamically allocating memory within those classes.New Keywords / Language concepts Classes conceptually similar to other languages The std::vector class similar to Javas ArrayList class, an expandable container The std::string class similar in many ways to strings in most every languageDescriptionThis program will represent a hypothetical car dealership, which consists of showrooms that contain thevehicles for sale. To that end, there are three classes you will be writing: Vehicle Showroom DealershipFor this assignment, main.cpp will be provided for you, so you dont have to worry about the structureof the program. Instead, you can focus solely on the structure of the classes and their interactions.VehicleThe Vehicle class is The basic container of this assignment. You will need to store the following data asprivate data members of the class: A std::string to Store the make of the vehicle (such as Mazda, Toyota, etc) A std::string to store the model of the vehicle (such as Mustang, Model S, F-150, etc) An unsigned integer to store the year A float to store the price An unsigned integer to store the number of miles the vehicle has been drivenIn addition to these data members, you should have the following public functions:COP3503 写作COP3503作业、 辅导C++程序语言作业、Programming Fundamentals 2University of FloridaDefault values and constructorsWhile the definition of appropriate defaults may vary from one scenario to the next, for thisassignment you can use these values as your defaults:Make Model Year Price MileageCOP3503 Rust Bucket 1900 0 0These defaults are chosen arbitrarily for this assignmentfor your own projects, you can of coursechoose anything that you like.COP3503Programming Fundamentals 2University of FloridaShowroomThe Showroom class is a bit more sophisticated. Its purpose is to store a collection of Vehicle objects.Each Showroom that you create could have a different number of Vehicles (depending on its size), so forthis assignment Well use a vector. Your Showroom should contain variables for the following: The name of the Showroom A vectorVehicle to store Vehicle objects A maximum Capacity of the showroom (we dont want to add Vehicles beyond this limit)In addition, you should create the following functions:Function ReferenceConstructor Same as all constructors! Initialize class member variablesGetVehicleList Return the vectorVehicle objects, so other code can access itAddVehicle If the Showroom is already full (numberOfVehicles == capacity), then you shouldprint out Showroom is full! Cannot add 2015 Mazda Miata (this will usethe GetYearMakeModel() function from the Vehicle class)If there is space in the showroom, add the pass-in Vehicle to the class vector.Vector objects can be expanded with the push_back() function.ShowInventory Show all vehicles in the showroom, using the Display() function of each vehicleGetInventoryValue Sum up the prices of all vehicles in the showroom and return that valueCOP3503Programming Fundamentals 2University of FloridaDealershipThe Dealership class in some ways is very similar to the Showroom. Instead of Vehicles, it will store avector of Showroom objects. It will also need a name and a capacity. In addition, you will needfunctions:Constructor Same as all constructors! Initialize class member variablesAddShowroom If the Dealership is already full (numberOfShowrooms == capacity), then youshould print out Dealership is full, cant add another showroom!If there is space, add the passed-in Object to the vector class member.GetAveragePrice Here you will have to loop through all showrooms, and all vehicles in thoseshowrooms, and get a final average price of all vehicles.(Remember: Average is total / number of values)ShowInventory Show all showrooms stored in this dealership, one at a time, finally displayingthe average price of each vehicle stored in the dealership (this sounds familiar)Relevant ReadingzyBooks chapters:StringsArrays / Vectors (specifically the section on vectors)Objects and ClassesUser-Defined Functions (specifically the section on Pass by Reference)Canvas-Pages-strings a more in-depth look at stringsTipsA few tips about this assignment: You can print out a tab character (the escape sequence \t ) to help line up the output. Dont try to tackle everything all at once. Work on one class at a time. Cant really have aDealership without a Showroom, which really needs Vehicles An extension of that: work on One function, one class variable at a time. Create a constructor,initialize a single variable, test that out. When that works, move to the next part, and so on.COP3503Programming Fundamentals 2University of FloridaExample OutputDefault Constructor output1900 COP3503 Rust Bucket $0.00 0Unnamed Showroom is empty!Generic Dealership is empty!Average car price: $0.00Showroom output and error message when Showroom is fullShowroom is full! Cannot add Dodge Caravan 1992Vehicles in Example Showroom2018 Bugatti Chiron $12447.00 42013 Chrysler Sebring $1819.00 22987Dealership output And error message when Dealership is fullDealership is full, cant add another showroom!Vehicles in Room One1998 Dodge Neon $500.00 932018Vehicles in Room Two2001 Ford Escort $2000.00 1259002004 Ford F-150 $500.00 7392Average car price: $1000.00Calling just the GetAveragePrice() function of the dealershipUsing just the GetAveragePrice() functionAverage Price of the cars in the dealership: $19272.81如有需要,请加QQ:99515681 或邮箱:99515681@qq.com
“
添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导。






