Kat H.

asked • 08/07/21

C++. Change addToList to insert into the list in order by model

NOTE: Combined this exercise into the Exercise 1 code. No need for a separate project directory.


What To Do


Change the addToList to insert a new Car object in order by model. Don't worry if there is more than one car with the given model, this will still work.


Requirements

  1. Must have a linked list in your List class. NO ARRAYS (except for temporary C strings).
  2. Need functions for deleting from the list and adding to the list by make. LIst print in order by model.
  3. Need a destructor for the List class.
  4. Must have dynamic C strings in your Car class. No fixed arrays.
  5. Must have 6 files: car.h, car.cpp, list.h, list.cpp, main.cpp and makefile
  6. No function definitions in the car.h or list.h file. Only prototypes.


EXAMPLE OUTPUT #1

3 - delete a car
4 - quit
2
Enter make: Honda
Enter model: Civic
Enter year: 2018
1 - print list of cars
2 - add a car
3 - delete a car
4 - quit
1
make: Honda
model: Civic
year: 2018
1 - print list of cars
2 - add a car
3 - delete a car
4 - quit
2
Enter make: Ford
Enter model: Escort
Enter year: 2002
1 - print list of cars
2 - add a car
3 - delete a car
4 - quit
1
make: Honda
model: Civic
year: 2018
make: Ford
model: Escort
year: 2002
1 - print list of cars
2 - add a car
3 - delete a car
4 - quit
2
Enter make: Pierce
Enter model: Arrow
Enter year: 1933
1 - print list of cars
2 - add a car
3 - delete a car
4 - quit
1
make: Pierce
model: Arrow
year: 1933
make: Honda
model: Civic
year: 2018
make: Ford
model: Escort
year: 2002



1 Expert Answer

By:

Patrick B. answered • 08/08/21

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.