Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i need the program in c++. thank you Create a class that stores an animal, where an animal consists of a name, species, and weight

image text in transcribed
image text in transcribed
i need the program in c++. thank you
Create a class that stores an animal, where an animal consists of a name, species, and weight (in kg). You will need files such as animal.h, animal.cpp, and main.cpp. Remember that you can compile and run your program with these commands: > clang++ -Wall animal.cpp main.cpp -o animal > ./animal Your work for this lab should be done in the directory - CMPT276/Lab1 which you can create with the following commands (remember > at the start of a line indicates the command prompt, and should not be typed): > cd > mkdir CMPT276 > cd CMPT276 > mkdir Labi > cd Labi When you have completed your program demonstrate it to the instructor and upload your solution to Moodle in a single zip file. Submitting Your Work Submit your entire Lab1 directory as a .tar.gz archive, online through Moodle. You can do this with these commands: > cd /CMPT276 > tar cvzf LASTNAME.tar.gz Labi Double check that you have the right file before you submit. Uploading the wrong file will result in a mark of ZERO for the entire assignment. Program Specification: Your class should be called animal Use suitable information encapsulation techniques (ie, data members should be private and your print function should be constant). Public member functions should include the following: A default constructor in which the animal object's name, specie, and weight are initialized to undefined", "undefined", and respectively o A parametrized constructor in which the data member values are set via passing parameters to the constructor 1 o Getters (get_name, get_specie, and get_weight) which return the value of their respective data member Setters (set_name, set_specie, and set_weight) which can be used to change the value of their respective data member Add a member function to print out the animal. Example Output: Dumbo the Elephant is 700 kg. Demonstrate your class by creating and printing three animals from your main function. You may hard code your examples in your main function for this lab Example output: Starting program... Dumbo the Elephant is 700kg. Mr. Ed the Horse is 470kg, Garfield the Cat is 12kg Ending program... Additional Program Specification All files (hand.cpp) should include a comment at the top of the file with your name, and a brief description of what the file is for. (e.g., animal.h might say "Class definition for animal class, which stores the name, specie, and weight of an animal.") All functions should be properly documented in the header file, including PRECONDITIONS and POSTCONDITIONS (with those words). You do not need to include this in the function implementation as well . Your code should include appropriate comments, identifying variables (if needed) and describing what each section of code is doing. All identifiers (function and variable names) should be meaningful Your code should have proper Indentation and spacing. (Ask me if you are not sure.) Make your functions minimal -- do not pass in variables that you do not need Make sure to declare object inputs as const where appropriate. Functions which do not modify the object should be const

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

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

More Books

Students also viewed these Databases questions

Question

7. How will you provide encouragement and support?

Answered: 1 week ago

Question

2. Discuss the steps in preparing a manager to go overseas.

Answered: 1 week ago

Question

8. Measure the effectiveness of the succession planning process.

Answered: 1 week ago