Instructions: Put the class definition in EV.h and the implementation of the constructors and functions in EV.cpp 1. Define a class called "EV", that represents the information of an electric vehicle. The EV is defined with these attributes: model (string), range(int), unit (string) and year (int). Functions of the EV class must perform the following operations: A default constructor which sets all the numeric instance variables to zero. A constructor with 4 parameters which sets the 4 instance variables to the corresponding values passed. Implement a getter function for each of the 4 instance v
Instructions: Put the class definition in EV.h and the implementation of the constructors and functions in EV.cpp 1. Define a class called "EV", that represents the information of an electric vehicle. The EV is defined with these attributes: model (string), range(int), unit (string) and year (int). Functions of the EV class must perform the following operations: A default constructor which sets all the numeric instance variables to zero. A constructor with 4 parameters which sets the 4 instance variables to the corresponding values passed. Implement a getter function for each of the 4 instance v
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter10: Classes And Data Abstraction
Section: Chapter Questions
Problem 7SA: Assume the definition of class foodType as given in Exercise 6. Answer the following questions? (1,...
Related questions
Question
Please solve this C++ program as per ALL the instructions!!(Please read all the instructions and make sure to input the correct output as shown at the end of the pictures. Thank you for your help!
(NOTE: DO NOT verify the validity of user input. You are supposed to use the POINTERS at different parts of the code as instructed Please do not write it any other way even if the output is same as shown.
Instructions:
Put the class definition in EV.h and the implementation of the constructors and functions in EV.cpp
1. Define a class called "EV", that represents the information of an electric vehicle. The EV is defined with these attributes: model (string), range(int), unit (string) and year (int). Functions of the EV class must perform the following operations:
- A default constructor which sets all the numeric instance variables to zero.
- A constructor with 4 parameters which sets the 4 instance variables to the corresponding values passed.
- Implement a getter function for each of the 4 instance variables that will return the value of the instance variable. For example, the getX() function for the instance variable model must be called getModel().
- Implement a setter function for each instance variable that will assign to the instance variable to the value passed. For example, the setX() function for the instance variable model must be called setModel().
- An info function: this function print information of object as following format:
"EV"+[model]+ "manufactured in" + [year] + "has a range of" + [range] + [unit] - A Convert function: This function converts the range from kilometers to miles and from miles to kilometers and returns the result. If the user enters "miles" for the unit and the range in kilometers, then this function must return the miles. As same if user enters 'miles' for the unit and the range in miles, it must return the kilo-meter value. Using the two equations below:
Equation 1: miles= kilometers* 1.609
Equation 2: kilometers= miles* 0.6214 -
A Compare function: This function has one input parameter which is a pointer to an EV object and prints a message according to following criteria:
o If the range of first object (the object that the Compare function is called from) is greater than second object (input parameter in Compare, the program prints:
info of first object (using info function) + new line + "drives longer distance on a single charge than" + new line + print info of second object.
o If the range of first object is less than second object, the program prints:
info of first object (using info function) + new line + "drives shorter distance on a single charge than" + new line + print info of second object.
o If the range of first object is equal to second object, the program prints:
info of first object + new line + "drives the same distance on a single charge as" +new line + print info of second object.
2. Driver Class (EV_driver.cpp)
Create a file EV_driver.cpp with the main function that asks the user to enter the information of two EV objects and it dynamically creates two objects of type EV. Then, using Convert, Info and Compare functions, the following results are displayed: (Text in green is user input)
(Please include the text of 3 code files : EV.h, EV.cpp, EV_driver.cpp as well as screenshots of the output.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,