Question: in c++ please you will need these files 1 baddogs.txt with this inside Rover 10 baddog Tim 12 Grogu 50 Jeddi 2 dogs.txt with this
in c++ please
you will need these files
1 baddogs.txt
with this inside
Rover 10 baddog
Tim 12
Grogu 50 Jeddi
2 dogs.txt
with this inside
Rover 10 baddog
Tim 12 Terrier
Grogu 50 Jeddi
In this exercise, you will write a program that loads information about dogs from a text file and displays the data to the user in a formatted table. The name of the text file should be provided as a command line argument. Error messages should be displayed if the file name is missing on the command line, if the file is not found, or if the file is not formatted correctly for input.
Sample Output
./pet_manager Correct usage: ./pet_manager filename ./pet_manager notafilerealfile File notafilerealfile could not be opened ./pet_manager baddogs.txt The data file is not formatted correctly ./pet_manager dogs.txt Name Age Breed ====================== Rover 10 baddog Tim 12 Terrier Grogu 50 Jeddi The oldest dog is 50 years old. Its name is Grogu
Required Files and Classes
The following files are required for the project:
-
driver.cpp
-
Class: Dog
-
dog.h
-
dog.cpp
-
-
Class: DogManager
-
dogmanager.h
-
dogmanager.cpp
-
-
Class: DogTablePrinter
-
dogtableprinter.h
-
dogtableprinter.cpp
-
-
makefile
File: driver.cpp The important concepts in this project are in the Dog and DogManager classes. The driver.cpp file has therefore been supplied to you to provide guidance in using the classes. The main function shows how the other classes are to be used.
| Warning | You must use this file as-is. Modifications are not allowed. |
| Important | You will need to provide default and copy constructors for both the Dog and DogManager classes in addition to the parameterized constructors outlined below. |
Class: DogManager
Files
dogmanager.h, dogmanager.cpp
Overview
These files should implement the DogManager class. The class is responsible for loading and maintaining dog data. The implementation of functions for the class must be in the cpp file, not the h file.
Attributes
The following are the required private attributes of the DogManager class:
vectordogList; // holds dogs loaded from file
Functions
The following are the required functions for the class. You may add other private functions as needed. The public interface should not change.
Getters and Setters
This is a case where you do not create getters and setters. The dogList should only be manipulated internally. The class can optionally pass it to other classes as needed (in this case, the DogTablePrinter class).
Function: DogManager dm(string filename) (parameterized constructor)
Input: the name of the file containing the dog information
Output: instance of DogManager class
This constructor should call the private function loadDogs (see below).
Function: loadDogs(string filename)
Access level: private
Input: the name of the file containing the dog information
Returns: instance of DogManager class
The pseudo-code below shows the expected flow for this function:
open file for each line in the file read the line create a dog object and add it to the vector of dog objects
Exceptions: This function must throw an exception if the file supplied cannot be opened. The message should read "File
Technical requirements: This function populates the private attribute vector
Function oldestDog()
Access level: public
Input: None
Returns: the Dog object that has the highest age of those currently loaded
Function printDogs()
Access level: public
Input: None
Returns: None
Output: Prints a table to the console.
This function delegates printing to the DogTablePrinter class by calling printDogTable. See the class description below.
Class: DogTablePrinter
Files
dogtableprinter.h, dogtableprinter.cpp
Overview
This class encapsulates the printing of the table. Note that this class has no attributes, so that it could be designed to have only static functions. This will be discussed later in the semester.
Attributes
See above.
Functions
Only one public function is required. You may use private functions as needed.
Function printDogTable()
Access level: public
Input: vector
Return: none
Output: prints table of dogs. See the example output above for the required output format
Class: Dog
Files
dog.h, dog.cpp
Overview
These files should implement the Dog class. The class is responsible for holding all attributes of a dog. The implementation of functions for the class must be in the cpp file, not the h file.
Attributes
The following are the required private attributes of the Dog class:
string name; // name of the dog int age; // its age in years string breed; // the dog breed (Terrier, Bloodhound, etc.
Functions
The following are the required functions for the class. You may add other private functions as needed. The public interface should not change.
Getters and Setters
Create getters and setters for all class attributes.
Function Dog(string name, int age,string breed)
Access level: public
Input: dog name, age, and breed
Return: instance of Dog object (this is constructor, so no explicit return!)
thank you for any help
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
