C++ Dont include new files.
READ ME
Pets
Breed Class
Create a Breed class with the following:
Member Variables
Create the following private member variables, all of type std::string:
species_
breed_name_
color_
Constructors
Create a default constructor for Breed that sets its species_ to "Dog", breed_name_ to "Pug", and color_ to "Fawn".
Create a non-default constructor that receives a std::string for species_, breed_name_, and color_; in that order. The values from the constructor should appropriately assign the member variables.
Accessors and Mutators
Create accessors and mutators for all member variables, following the naming conventions covered in class. e.g. for species_, name the accessor Species, and the mutator SetSpecies.
Pet Class
Create a Pet class with the following:
Member Variables
Create the following private member variables:
std::string name_
Breed breed_
double weight_
Constructors
Create a default constructor for Pet that sets its name to "Doug" and weight to 15.6. The Breed object will automatically be created using its default constructor.
Create a non-default constructor that receives an std::string for name_, Breed for breed_, and a double for weight_ in that order. The values from the constructor should appropriately assign the member variables.
Create another non-default constructor that receives an std::string for name_, std::string species_, name_, and color_ for the Breed constructor, and double for weight_. The values from the constructor should appropriately assign the data members.
Accessors and Mutators
Create accessors and mutators for name_, breed_, and weight_. Please name the accessor for breed_ as GetBreed, to avoid conflicting with the constructor for the Breed class.
SetBreed overload
Create a function overload for SetBreed that accepts a species_, name_, and color_, all of type std::string, that will internally create a Breed object using the values provided and then assign it to the breed_ member variable.
Print
Create a member function called Print that returns void and does not take in any parameters. Using the member variables, this function should print out the name and weight of the Pet. It should also utilize accessors of the Breed class to get the species, breed name, and color.
Other instructions
Complete the main function as described. Place the Pet class in pet.h, and the Breed class in breed.h. Member functions that take more than ten lines or use complex constructs should have their function prototype in the respective .h header file and implementation in the respective cc implementation file.
main.cc file
#include <iostream>
int main() {
// == YOUR CODE HERE ==
// 1. Create a
// Don't forget to #include <vector> and "pet.h"
// ====
std::string name;
std::string breed_name;
std::string species;
std::string color;
double weight = 0.0;
do {
std::cout << "Please enter the pet's name (q to quit): ";
std::getline(std::cin, name);
if (name != "q") {
std::cout << "Please enter the pet's species: ";
std::getline(std::cin, species);
std::cout << "Please enter the pet's breed: ";
std::getline(std::cin, breed_name);
std::cout << "Please enter the pet's color: ";
std::getline(std::cin, color);
std::cout << "Please enter the pet's weight (lbs): ";
std::cin >> weight;
std::cin.ignore();
// == YOUR CODE HERE ==
// 2. Create a Pet object using the input from the user
// Store the newly-created Pet object into the vector.
// ====
}
} while (name != "q");
std::cout << "Printing Pets:\n";
// ==== YOUR CODE HERE ====
// 3. Print information about each pet in the `pets`
// vector by writing a loop to access each Pet object.
// ====
return0;
}
pet.h file
#include <string>
#include "breed.h"
// == YOUR CODE HERE ==
// Write the Pet class here. Refer to the README for the member
// variables, constructors, and member functions needed.
//
// Note: mark functions that do not modify the member variables
// as const, by writing `const` after the parameter list.
// Pass objects by const reference when appropriate.
// Remember that std::string is an object!
// ===
breed.h file
#include <string>
// == YOUR CODE HERE ==
// Write the Breed class here. Refer to the README for the member
// variables, constructors, and member functions needed.
//
// Note: you may define all functions inline in this file.
// ====
pet.cc file
#include "pet.h"
#include <iomanip>
#include <iostream>
// == YOUR CODE HERE ==
// This implementation file (pet.cc) is where you should implement
// the member functions declared in the header (pet.h), only
// if you didn't implement them inline within pet.h.
//
// Remember to specify the name of the class with :: in this format:
// <return type> MyClassName::MyFunction() {
// ...
// }
// to tell the compiler that each function belongs to the Pet class.
// ===
Step by stepSolved in 8 steps
I still dont understand the addition of a new file breed.cc when there should only be 4 files. Main.cc, breed.h, pet.h, and pet.cc. How would I create a new file or even add it into an existing file of the 4 available.
I still dont understand the addition of a new file breed.cc when there should only be 4 files. Main.cc, breed.h, pet.h, and pet.cc. How would I create a new file or even add it into an existing file of the 4 available.
- Summary In this lab, you create a derived class from a base class, and then use the derived class in a Python program. The program should create two Motorcycle objects, and then set the Motorcycle’s speed, accelerate the Motorcycle object, and check its sidecar status. Instructions Open the file named Motorcycle.py. Create the Motorcycle class by deriving it from the Vehicle class. Call the parent class __init()__ method inside the Motorcycle class's __init()__ method. In theMotorcycle class, create an attribute named sidecar. Write a public set method to set the value for sidecar. Write a public get method to retrieve the value of sidecar. Write a public accelerate method. This method overrides the accelerate method inherited from the Vehicle class. Change the message in the accelerate method so the following is displayed when the Motorcycle tries to accelerate beyond its maximum speed: "This motorcycle cannot go that fast". Open the file named MyMotorcycleClassProgram.py. In the…arrow_forwardProgram SpecificationUsing python, design a class named PersonData with the following member variables: lastName firstName address city state zip phone Write the appropriate accessor and mutator functions for these member variables. Next, design a class named CustomerData , which is derived from the PersonData class. The CustomerData class should have the following member variables: customerNumber mailingList The customerNumber variable will be used to hold a unique integer for each customer. The mailingList variable should be a bool . It will be set to true if the customer wishes to be on a mailing list, or false if the customer does not wish to be on a mail-ing list. Write appropriate accessor and mutator functions for these member variables. Next write a program which demonstrates an object of the CustomerData class in a program. Your program MUST use exception handling. You can choose how to implement the exception handling. Start your program with a welcome message Make sure…arrow_forwardIn c++ Create a class named Restaurant that has two member objects: a Burger object, and a Fries object. In addition to this, it also has a member variable named name, to allow you to name your Restaurant. Burger has two member variables: double weight; int number_of_toppings; Fries has two member variables: string potato_type; char size; Write the code for all three classes. You will need to determine what functions are necessary to initialize all the members of the Restaurant class and write those necessary functions. Finally, you will write the code in the main that you would use to declare a Restaurant object, and set the different member variables.arrow_forward
- People in School Objective: At the end of the activity, the students should be able to: Create a program that exhibits inheritance. Procedure: Write a simple information system that will store and display the complete information of a student, faculty, or employee. Create four (4) no-modifier classes named Person, Student, Faculty, and Employee. Create a public class named CollegeList. This class shall contain the main method. Refer to the UML Class Diagram for the names of the variables and methods. The (-) symbol represents private variables, while (+) represents public method. This should be the sequence of the program upon execution: Prompt the user to select among Employee, Faculty, or Student, by pressing E, F, or S. Ask the user to type the name and contact For Employee, ask the user to type the employee's monthly salary and the department where he/she belongs to (Ex. Registrar). Then, display name, contact number, salary, and For Faculty, ask the user to press Y if…arrow_forwardFill-in-the-Blank A constructor that takes a single parameter of a type different from the class type is a __________ constructor.arrow_forwardUsing C++ define the class called Student. The Student class has the following: Private data members: name(string), age(int), units(int). The units represent the number of quarter units student is enrolled in. Define a default constructor as well as a constructor with parameters for the class Student. The class must have get and set functions for all private data members. The set function for the data member units must throw “out_of_range” exception if the number of units is not between 1 and 15. Include a function called tuition (double feePerUnit) that computes and returns the cost of registering for the number of units (in the private data member). The function receives the cost per unit as a parameter. Overload the operator (<<) to display student name and age. Test the class Student by writing a main program in which a Student object is created and displayed. Call the function tution(), you may pass any value as feePerUnit parameter to this function and display the…arrow_forward
- Write C++ code for a class named MuniBus that has the following private member variables: int totalPassengers; double faresCollected; and the following public member functions: void passengerBoard() - adds 2.50 to faresCollected and adds 1 to totalPassengers double getFaresCollected() - returns faresCollected int getPassengers() - returns totalPassengers void reset() - sets totalPassengers and faresCollected to zero MuniBus() - default constructor. Initializes both totalPassengers and faresCollected to 0 MuniBus(int tp, double fc) - constructor which initializes totalPassengers to tp, faresCollected to fc ~MuniBus() - destructor. Prints out a message saying that the bus is being destroyed, and also prints out totalPassengers and faresCollected. Write the class declaration and implement all of the constructors, the destructor, and member functions. You do not need to demonstrate using your class or show output.arrow_forwardC++ Question Hello Please answer the attached C++ programming question correctly, just as the prompt states. Also, make sure that the code is working properly. Thank you.arrow_forwardC:/Users/r1821655/CLionProjects/untitled/sequence.cpp:48:5: error: return type specification for constructor invalidtemplate <class Item>class sequence{public:// TYPEDEFS and MEMBER SP2020typedef Item value_type;typedef std::size_t size_type;static const size_type CAPACITY = 10;// CONSTRUCTORsequence();// MODIFICATION MEMBER FUNCTIONSvoid start();void end();void advance();void move_back();void add(const value_type& entry);void remove_current();// CONSTANT MEMBER FUNCTIONSsize_type size() const;bool is_item() const;value_type current() const;private:value_type data[CAPACITY];size_type used;size_type current_index;};} 48 | void sequence<Item>::sequence() : used(0), current_index(0) { } | ^~~~ line 47 template<class Item> line 48 void sequence<Item>::sequence() : used(0), current_index(0) { }arrow_forward
- In C++arrow_forwardC++ coding project just need some help getting the code thank you!arrow_forward/* Interface File: Movie.h Declaration of Movie Class (Variables - "Data Members" or "Attributes" AND Functions - "Member Functions" or "Methods") */ #ifndef MOVIE_H // Include Guard or Header Guard -If already defined ignore rest of code #define MOVIE_H // Otherwise, define MOVIE_H #include<string> // Note: Not "using namespace std;" or even "using std::string" class Movie { private: std::string title = ""; // Explict scope used --> std::string int year = 0; public: Movie(std::string title = "", int year = 1888); // Declaring a Default Constructor ~Movie(); // A Destructor used for freeing up resources void set_title(std::string title_param); std::string get_title() const; // "const" safeguards class variable changes within function std::string get_title_upper() const; void set_year(int year_param); int get_year() const; }; //…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education