Java Program

 

Project: Fear 

 

 

 

Let’s create a simulation. Children are out Trick Or Treating in various costumes having a great time. But real monsters are lurking about trying to get them! Imagine your neighborhood plotted out on graph paper with each co-ordinate x and y. The trick or treaters are at their co-ordinates and various monsters are at their own co-ordinates. If the trick or treater plays a trick on a monster, it may dispel the monster. However, if the monster attacks first, it may be the end of our trick or treater.

 

* Create UML diagrams for the classes. We will use 2 classes for the monsters and trick or treaters and a main class you will name Project4. Use following information to also determine the variables with their ranges, default values, etc.

 

* Classes have their own files

 

Added Classes:

 

Class Monster

  variables (remember to make them all private to protect them, and set default values in the constructors.

  – String monsterName, Count Dracula, Red Dragon, Skeleton, etc.

  – String weapon

  – int weaponType, 0=fangs, 1=breathes fire, 2=claws, 3=spits, etc.

  – int xPosition

  – int yPosition

 

  methods

  – Monster() at least 2 constructors. Set default values for those not passed into the constructor.

  – get() methods

  – set() methods, this is where you check if the input is valid. String length and number range (hint, how large is your map?).

  – attack(x, y) x,y of target. Target must be same position of monster unless range attack. Suggestions, 0-5 = melee (bite, claw, etc), 6+ range (spit, fire breath, etc)

  – move(x, y) updates xPosition, yPosition using the set() methods. 

  – toString() returns a string to print info on the monster.

 

 

Class TrickOrTreater

  variables (remember to make them all private to protect them, and set default values in the constructors.

  – name of the trick or treater

  – String costume

  – String trickType, scream, toiletPaper the monster, etc.

  – int xPosition

  – int yPosition

 

  methods

  – TrickOrTreater() at least 2 constructors. Ã¥Set default values for those not passed into the constructor.

  – get() methods

  – set() methods, this is where you check if the input is valid. String length and number range.

  – attack(x, y) x,y of target.

  – move(x, y) x,y is the destination, update xPosition, yPosition

  – toString() returns a string to print info on the trick or treater.

 

 

* Attacks in this case shouldn’t be printed in the class/object since the victim isn’t known, only the coordinates of the victim. Please think about this fact so you’ll realize this when designing in the future.

test RIGOROUSLY everything in a main() method with command line inputs especially get(), set() and attack() methods

* create a package, compress it into a .jar file, import the .jar file into a new project

1. be sure the private methods & variables you want private, are declared private and public are declared public

2. right-click on the project name on the left side of the screen

3.  select “Properties” on the drop-down menu

4.  under “Categories:”, then “Build”, then click on the bullet called “Packaging”

5.  check the box next to, “Compress JAR File”

6. next, Clean and Build

7. start a NEW project and call it anything

8. right-click the “Libraries folder in your new project and select “Add JAR/Folder

9. find your new .jar file and add it ex: import Infestation.Agent;

 

* Finally, after you import your new package into a new project, test it all again.

 

 

Once completed, use this checklist: 

 

CLASSES

– classes created correctly & in separate files

– complete and correct info. at the top

– formatted correctly

– correct naming convention

– private variables

– correct use of getters & setters

– overloaded constructors

– overridden toString() method

 

MAIN

– project compiles

– project runs without crashing

– object instantiation

– range checking

– use of move()

– use of toString()

 

JAR

– .jar file works correctly when imported into another project

 

 

 
Looking for a similar assignment? Our writers will offer you original work free from plagiarism. We follow the assignment instructions to the letter and always deliver on time. Be assured of a quality paper that will raise your grade. Order now and Get a 15% Discount! Use Coupon Code "Newclient"