Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in c++ please thank you for any help In this exercise, you will write a program that loads information about dogs from a text file

in c++ please

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

thank you for any help

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_anager 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 Breed Rover baddog Tim 12 Terrier Grogu 50 Jeddi The oldest dog is se years old Its name is Grogu Required Files and Classes The following files are required for the project: . driver.cpp Class: Dos dog.h dog.cpp Class: DogManager dogmanager.ch . dogmanager.cpp Class: DogTablePrinter dogtableprinter.h dogtableprinter.cpp makehle 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 Waming You must use this file as-is. Modifications are not allowed. You will need to provide default and copy constructors for both the Dog and Dogmanager classes in addition Important to the parameterized constructors outlined below. Class: Dogmanager Files dogmanager.n) dogmanager.cpp Overview These files should implement the Dogmanager dass. The class is responsible for loading and maintaining dog data. The implementation of functions for the dass must be in the cpp file, not the file. Attributes The following are the required private attributes of the Dogmanager) class: vector Dogdog list; 1/ 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 dass can optionally pass it to other classes as needed (in this case, the DogTablePrinter dass). Function: Dogohanager dn strng Filename)) (parameterized constructor Input: the name of the file containing the dog information Output instance of Dogmanager dass This constructor should call the private function Leadbog) (see below). Function: loadDogs (string filename) Access level: private Input: the name of the file containing the dog information Returns: instance of Dagmanager dass 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 could not be opened", where filename> is the name of the file that was supplied on the command line. Technical requirements: This function populates the private attribute vactor Dog doglist) Function aldestpog() 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) dass by calling (printDog Table). See the class description below. Class: DogTablePrinter Files dogtableprinter..), 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 printDog Table() Access level: public Input vector cog containing all the dogs that have been loaded in the system Return: none Output: prints table of dogs. See the example output above for the required output format Class Dog Files dog. 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 hile, not the hile. Attributes The following are the required private attributes of the Dog class. string nane; // name of the dog // its age in years string breed; // the dog breed (Terrier, Bloodhound, etc. Functions The following are the required functions for the dass. You may add other private functions as needed. The public interface should not change 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 nane, int uge, string breed) Access level: public Input dog name, age, and breed Retur: instance of Dog object this is constructor, so no explicit return! 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_anager 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 Breed Rover baddog Tim 12 Terrier Grogu 50 Jeddi The oldest dog is se years old Its name is Grogu Required Files and Classes The following files are required for the project: . driver.cpp Class: Dos dog.h dog.cpp Class: DogManager dogmanager.ch . dogmanager.cpp Class: DogTablePrinter dogtableprinter.h dogtableprinter.cpp makehle 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 Waming You must use this file as-is. Modifications are not allowed. You will need to provide default and copy constructors for both the Dog and Dogmanager classes in addition Important to the parameterized constructors outlined below. Class: Dogmanager Files dogmanager.n) dogmanager.cpp Overview These files should implement the Dogmanager dass. The class is responsible for loading and maintaining dog data. The implementation of functions for the dass must be in the cpp file, not the file. Attributes The following are the required private attributes of the Dogmanager) class: vector Dogdog list; 1/ 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 dass can optionally pass it to other classes as needed (in this case, the DogTablePrinter dass). Function: Dogohanager dn strng Filename)) (parameterized constructor Input: the name of the file containing the dog information Output instance of Dogmanager dass This constructor should call the private function Leadbog) (see below). Function: loadDogs (string filename) Access level: private Input: the name of the file containing the dog information Returns: instance of Dagmanager dass 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 could not be opened", where filename> is the name of the file that was supplied on the command line. Technical requirements: This function populates the private attribute vactor Dog doglist) Function aldestpog() 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) dass by calling (printDog Table). See the class description below. Class: DogTablePrinter Files dogtableprinter..), 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 printDog Table() Access level: public Input vector cog containing all the dogs that have been loaded in the system Return: none Output: prints table of dogs. See the example output above for the required output format Class Dog Files dog. 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 hile, not the hile. Attributes The following are the required private attributes of the Dog class. string nane; // name of the dog // its age in years string breed; // the dog breed (Terrier, Bloodhound, etc. Functions The following are the required functions for the dass. You may add other private functions as needed. The public interface should not change 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 nane, int uge, string breed) Access level: public Input dog name, age, and breed Retur: instance of Dog object this is constructor, so no explicit return

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

Database Management With Website Development Applications

Authors: Greg Riccardi

1st Edition

0201743876, 978-0201743876

Students also viewed these Databases questions

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago