This lab is due by Friday, November 08, 2019, 11:59 PM.
As with all labs you may, and are encouraged, to pair program a solution to this lab. If you choose to pair program a solution, be sure that you individually understand how to generate the correct solution.
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 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 double
s) 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 a random default value.
Now in main, create two Godzilla
objects - one named godzilla
and the other named mechagodzilla
.
godzilla
should be created using the default constructor. Prompt the user to provide
the health and power of mechagodzilla
so the parameterized constructor can be used.
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 Set7. Detailed instructions for doing this are posted in Assignment 7.
This lab is due by Friday, November 08, 2019, 11:59 PM.
As with all labs you may, and are encouraged, to pair program a solution to this lab. If you choose to pair program a solution, be sure that you individually understand how to generate the correct solution.