Classes & Objects


Using and Creating Classes

Hero.java
HeroHarness.java
Monster.java

Deitel ch 3


Classwork

When example code is given, you may use it as a model when doing assignments, unless I say otherwise. You should use nothing beyond what we have covered in class or is given in example code (e.g. even if you know about accessors and mutators, don't use them yet).
Part A

Create a project and add to it the given example classes Hero and Monster (easiest way to do this is to add classes with those names, then copy-paste my code) You will probably need to fix the package statement to match your package name.

Call your class with a  main method HeroAndMonster.

In the main method:

(You can base this code on HeroHarness but use different variable names and values. )

Continuing in main:
Part B

You will create a class modeling some specific type of creature. You can choose any type of creature you want -- capybara, grue, naked mole rat, creeper, zombie dinosaur, whatever except the examples we've already done such as generic monster, cat, dog, or bunny.  You can use Hero as a model.  Name the class based on the specific type of creature it is modeling (i.e. public class ZomebieDino, not just public class Creature)

Create the new class in the same package as part A.  If it shows up in a different package (<default package>), you didn't do new on the package, drag it to the right package.

For your new creature class

Further down in the main of your HeroAndMonster, create an instance of your new class, and test setting all variables and calling all methods.