This lab is due by Tuesday, June 18, 2019, 11:59 PM.
As with all labs you may, and are encouraged, to pair program a solution to this lab.
Concepts
Focus on defining a Godzilla class from
scratch.
Suggestion: Use NotePad or WordPad
Consider using NotePad or WordPad on your computer to write your code
for this lab. Once you feel good about what you've written, then copy
the code into your project. Doing this will help you see where
you might make mistakes on the exam!
You should write a
main.cpp
that tests each feature of your class works as expected. You
will need to submit your class declaration file, your class
definition file, and your
main.cpp
file for this lab.
Godzilla Class
We are going to declare a class called
To verify your objects are correct, output the health & power of Godzilla and Mechagodzilla.
Godzilla
that will allow us to ultimately simulate a battle
between Godzilla & Mechagodzilla.
Create a new class called Godzilla
that
contains data members for storing the name (as a string), the health and power (as doubles) of a Godzilla creature.
Functions you should include in your class:
- A default constructor that sets the name to "Godzilla", the health to a random value between [50, 100], and the power to a random value between [10, 25].
- A parameterized constructor that allows a user to enter a new Godzilla object specifying the name, health, and power. Ensure that the provided health and power are both greater than zero. If either are not, then reassign it to the random default values.
To verify your objects are correct, output the health & power of Godzilla and Mechagodzilla.
Lab Submission
You will submit your solution to this lab with the rest of Set8. Detailed instructions for doing this are posted in Assignment 8.
This lab is due by Tuesday, June 18, 2019, 11:59 PM.
As with all labs you may, and are encouraged, to pair program a solution to this lab.