weixin_43455308 2018-11-10 08:29
浏览 384

C++作业,一个汽车管理系统,求助,吼难

This assignment focus on: • Inheritance
o abstractbaseclass o polymorphism
o dynamic binding
• Composition using container class
• Deep copying and dynamic memory allocation
o copy constructor
o assignment operator o destructor
Car handling system
Todays’ cars can be divided into cars that uses electricity and cars that uses fossil fuel (there are also cars that uses both electricity and fossil fuel but we will not consider those here).
A small company has cars of both kinds (cars that uses fossil fuel and cars that uses electricity) and the company wants a system to handle these cars. The person responsible for de design of this system has decided to implement a prototype (and this is your task) in which inheritance is used. The information that must be registered for all cars in the system is registration number, model and engine power (kW). Concerning electric cars, also the range of the car (how far in km it can be driven on a fully charged battery) needs to be registered. For car that uses fossil fuel instead the fuel consumption (liter/kilometer) and the volume of the fuel tank (liters) needs to be registered. Furthermore:
• the classes FossilCar and ElectricCar must be defined in an inheritance hierarchy
• the base class Cart must be abstract
• no member function (except for the destructor) can have empty bodies
• dynamic binding must be used (hint: virtual)
• all cars must be able to return their model
• all cars must be able to return their registration number
• all cars must be able to return a string that contains all information of the car
• all cars must be able to return their range (cars that uses fossil fuel must calculate this)
• cars that use fossil fuel must be able to return their consumption
• it is not allowed for member functions to make screen outputs
All cars should be handled in a management system that have the functionality given below:
1) Add a car that uses electricity as fuel using user input
2) Add a car that uses fossil fuel using user input
3) Remove a car given the registration number. The user inputs the registration number
4) Present all cars with all information (both cars with fossil fuel and with electricity) and also the
range for each car.
5) Present all cars that uses fossil fuel (all information)
6) Present all cars that uses electricity as fuel (all information)
7) Calculate the average of consumption of all cars that uses fossil as fuel
8) Present the car that that has the longest range and uses electricity as fuel
9) Find and present the car/cars that uses electricity as fuel that has a range that is more than a
certain value. The user inputs this value.
Besides the inheritance hierarchy you shall also create a class containing the cars (a car container class) in which one (1) statically allocated array of pointers to base class, with the capacity of 15, is used to keep / store all the cars.
In the car container class, you shall also implement copy constructor, assignment operator and a virtual destructor – deep copying is required!
Keyboard input and screen output in the functions within the car container class are not allowed. All cars must always be placed consecutive in the array.
Finally, you shall implement a file containing the main function which corresponds to a menu-based system for handling cars with the functionality described above in 1) – 9).
Other requirements:
• No memory leaks are allowed!
Use:
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); at the top of main function and run in debug-mode to detect memory leaks.
• Only private member variables are allowed
• All classes shall be divided into header- and cpp-files.
• The possibility to implement constant member functions shall be used
• Global variables are not allowed
• The menu based system shall handle separate part problems in separate functions

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#python#的问题:求帮写python代码
    • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
    • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
    • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
    • ¥15 perl MISA分析p3_in脚本出错
    • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
    • ¥15 ubuntu虚拟机打包apk错误
    • ¥199 rust编程架构设计的方案 有偿
    • ¥15 回答4f系统的像差计算
    • ¥15 java如何提取出pdf里的文字?