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 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog