Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm needing help with this project. This is coded in C++ I keep getting segmentation fault, core dump when I click option 2. It doesn't

I'm needing help with this project. This is coded in C++image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

I keep getting segmentation fault, core dump when I click option 2. It doesn't seem to want to take in the HighTechAgency.txt file.

Objectives: The main objectives of this project is to test your ability to create and use C++ classes, with multiple constructors, static members/functions, and expand to operator overloading A review of pointers, structs, arrays, iostream, file I/O and C-style strings is aso included This project will significantly expand upon Projeet 3 by adding additional functionality, and implementing more abstract data types (ADTs) and their operations through classes. Pointers must be used for all array manipulation, including arrays with ADTs (structs, classes)eg, rental cars, rental agencies. Pointers must be used in function prototypes and function parameter lists not square brackets. Make sure all your Cstring functions (e.g. string copy, string compare, ctc.) work with pointers (parameters list and function implementation). Const shoud be used in parameter lists, functions, and function signatures as appropriate. Square brackets should be used Pointer arithmetic (e-gand setting the pointer back to the base address using the array name can be used to move through arrays if otherwise you specify your own overloaded operator The additional functionality is as follows: You are given an updated data le where there is 1 Agency location (Agency) which has 5 cars (Car) which can potentialy be of a high-tech type. Each car can incorporate up to 3 (0-3) special driving sensors (Sensor). 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 significandly easier. The Sensor Class will contain the following private data members: m type, a C-string char array of 256 max characters (name of sensor type), valid strings for Sensor mtype are "gps", "camera", "lidar", "radar", "none" m extracost, a float (additional rent cost per day for the car that carries the sensor, for gps: $5.0/day, for "camera: $10.0/day, for "lidar $15.0/day, for radar $20.0/day, for "none": -$0.0/day) gps cnt, a static int member (keeps track of existing gps-type sensors) camera cnt, a static int member keeps track of existing camera-type sensors) lidar_cnt, a atatic int member (keeps track of existing lidar-type sensors) radar ent, a static int member (keeps track of existing radar-type sensors) and will have the following methods: Default Constructor- will set the aforementioned data members to default initial values. Parameterized Constructor-will create a new object based on a C-string value passed into it (sensor type being instantiated). Hint bear in mind what a sensor "type" implies about ts other data members. Copy Constructor - will create a new objeet which duplicates an input Sensor Object. get/set methods for appropriate data member(s). A get and a reset static member function to return and to reset each of the static A Method to check if 2 Sensor Objects are the same. You mus implement this as an operator overload of (operator), and more specifically as a regular function (on- Member function of the Class The Car Class will contain the following private data members m make, a C-string char array of 256 max characters (ear make) m model, a Cstring char array of 256 max characters (car model) m year, anint (year of production) m sensors, a Sensor class type array of size 3 (max allowable number of sensors per car). Hist You are allowed to use an auxiliary member variable of your choice to keep track of how many actual sensors exist onboand, this will also help for instance in case adding a new m baseprice, a float (price per day for the sensorkss vehicle) finalprice, a float (price per day with the increased cost of the car sensors) m available, a boolfae try to display true/false using the std: :boolalpha" manipulator like: cout = 1 if the first charactor that doe not match has a higher value in stri than in stri2 int myseringCompare (eonst charstrl, const charstr2) // copies characters from source to destination array until a NULL-character .\0' found in source, tan it NULL-terminat0 destination too // returns a pointer to the destination array // appends the content of source to the destination array // this nean$ that the NULL-tartinator of de tination is overvritten by the first character of source and a NULL-character 0is appended at the end of the concatenated Cotring in destination // roturn a pointer to tho destination array char * ny tringcat(char * destination . oonat dhar * 0urce); The other functionality and structure of the program should remain the same as Project #3, 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 (required)! Use the const keyword where appropriate (almost everywhere you ean make it work)! Implement Class Constructors with Initializer-Lists (advised) Implement operator overloads (required)! This is a chance to experiment as much as possiblie with more advanced concepes and the intricacies of classes. It is not strict requirment that const data mcmlers ach can only be nstantiated with a list initialization are there in your code right now. Try your best in onder to acquaint yourself with the new concepes of this Project however, and figure out what might be giving you a hand time understanding and/or implementing at this early point Enterprise 89502 2014 Toyota Tacoma 115.12 (gps) 1 2012 Honda CRV 85.10 (camera lidar) 0 Mike 2011 Toyota Rav4 65.02 11 0 Oscar 2009 Dodge Neon 45.25 camera lidar radar) 1 2015 Ford Fusion 90.89 (lidar 0 Juliet Objectives: The main objectives of this project is to test your ability to create and use C++ classes, with multiple constructors, static members/functions, and expand to operator overloading A review of pointers, structs, arrays, iostream, file I/O and C-style strings is aso included This project will significantly expand upon Projeet 3 by adding additional functionality, and implementing more abstract data types (ADTs) and their operations through classes. Pointers must be used for all array manipulation, including arrays with ADTs (structs, classes)eg, rental cars, rental agencies. Pointers must be used in function prototypes and function parameter lists not square brackets. Make sure all your Cstring functions (e.g. string copy, string compare, ctc.) work with pointers (parameters list and function implementation). Const shoud be used in parameter lists, functions, and function signatures as appropriate. Square brackets should be used Pointer arithmetic (e-gand setting the pointer back to the base address using the array name can be used to move through arrays if otherwise you specify your own overloaded operator The additional functionality is as follows: You are given an updated data le where there is 1 Agency location (Agency) which has 5 cars (Car) which can potentialy be of a high-tech type. Each car can incorporate up to 3 (0-3) special driving sensors (Sensor). 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 significandly easier. The Sensor Class will contain the following private data members: m type, a C-string char array of 256 max characters (name of sensor type), valid strings for Sensor mtype are "gps", "camera", "lidar", "radar", "none" m extracost, a float (additional rent cost per day for the car that carries the sensor, for gps: $5.0/day, for "camera: $10.0/day, for "lidar $15.0/day, for radar $20.0/day, for "none": -$0.0/day) gps cnt, a static int member (keeps track of existing gps-type sensors) camera cnt, a static int member keeps track of existing camera-type sensors) lidar_cnt, a atatic int member (keeps track of existing lidar-type sensors) radar ent, a static int member (keeps track of existing radar-type sensors) and will have the following methods: Default Constructor- will set the aforementioned data members to default initial values. Parameterized Constructor-will create a new object based on a C-string value passed into it (sensor type being instantiated). Hint bear in mind what a sensor "type" implies about ts other data members. Copy Constructor - will create a new objeet which duplicates an input Sensor Object. get/set methods for appropriate data member(s). A get and a reset static member function to return and to reset each of the static A Method to check if 2 Sensor Objects are the same. You mus implement this as an operator overload of (operator), and more specifically as a regular function (on- Member function of the Class The Car Class will contain the following private data members m make, a C-string char array of 256 max characters (ear make) m model, a Cstring char array of 256 max characters (car model) m year, anint (year of production) m sensors, a Sensor class type array of size 3 (max allowable number of sensors per car). Hist You are allowed to use an auxiliary member variable of your choice to keep track of how many actual sensors exist onboand, this will also help for instance in case adding a new m baseprice, a float (price per day for the sensorkss vehicle) finalprice, a float (price per day with the increased cost of the car sensors) m available, a boolfae try to display true/false using the std: :boolalpha" manipulator like: cout = 1 if the first charactor that doe not match has a higher value in stri than in stri2 int myseringCompare (eonst charstrl, const charstr2) // copies characters from source to destination array until a NULL-character .\0' found in source, tan it NULL-terminat0 destination too // returns a pointer to the destination array // appends the content of source to the destination array // this nean$ that the NULL-tartinator of de tination is overvritten by the first character of source and a NULL-character 0is appended at the end of the concatenated Cotring in destination // roturn a pointer to tho destination array char * ny tringcat(char * destination . oonat dhar * 0urce); The other functionality and structure of the program should remain the same as Project #3, 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 (required)! Use the const keyword where appropriate (almost everywhere you ean make it work)! Implement Class Constructors with Initializer-Lists (advised) Implement operator overloads (required)! This is a chance to experiment as much as possiblie with more advanced concepes and the intricacies of classes. It is not strict requirment that const data mcmlers ach can only be nstantiated with a list initialization are there in your code right now. Try your best in onder to acquaint yourself with the new concepes of this Project however, and figure out what might be giving you a hand time understanding and/or implementing at this early point Enterprise 89502 2014 Toyota Tacoma 115.12 (gps) 1 2012 Honda CRV 85.10 (camera lidar) 0 Mike 2011 Toyota Rav4 65.02 11 0 Oscar 2009 Dodge Neon 45.25 camera lidar radar) 1 2015 Ford Fusion 90.89 (lidar 0 Juliet

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions