1/10/2018
PROJECT REPORT ON Lab 7 and Lab 8
In this assignment we study and analysis the game requirement and follow the instruction for the given game code. As per given instruction the requirement is compile and run the lab 7 code and follow the instruction that is given in lab 7 document we design and development phase of the code according to lab7 word document and then as per given requirement is we need to add four location in our code so we add the 4 location that we had add in our java code ..for the purpose of location we use hardcodeddata.java file and then add the location using location class object name as we add four location so we create 4 object of location class in java 7 code provided code
We did this work in a team and we are three membe
Team Membe
1. Jyoti Rani: XXXXXXXXXX
2. Bijal Patel: XXXXXXXXXX
3. Harpreet: XXXXXXXXXX
Team member one study and analysis the game after that lab7 development as per guideline
Team member two design the class diagram design and implement lab8 development as per given deadline
Team member three designs and development of two new class for running the game
1)Treaseaure.java
2)AdventureGame
1 package mazegame;
2
3 import java.util.*;
for A
ayList and Random
4 import mazegame.entity.Player;
5 import mazegame.entity.Weapon;
6 import mazegame.entity.Armor;
7 import mazegame.entity.Treasure;
8
9
10
16 public class AdventureGame
17 {
18 public static void main(String[] args)
19 {
XXXXXXXXXXRandom g=new Random();
shared among other Players
XXXXXXXXXXScanner in=new Scanner(System.in);
Scanner used for menu input
XXXXXXXXXXboolean rested;
has user rested this turn already?
XXXXXXXXXXA
ayList
tempscore=new A
ayList
();
used to tempscoreorarily create the initial Treasure for each Playe
XXXXXXXXXXtempscore.add("potion");
XXXXXXXXXXtempscore.add("potion");
XXXXXXXXXXtempscore.add("scroll");
user's initial Treasure
27
create user Playe
XXXXXXXXXXPlayer user=new Player("User", new Weapon("Sword", 2, 1, 8), new Armor("Leather armor", 10), new Treasure(tempscore), 50, g);
29
30
user will fight up to 8 Players
XXXXXXXXXXPlayer[] them=new Player[8];
32
33
create them[0]-them[5] and them[7], them[6] created late
XXXXXXXXXXtempscore=new A
ayList
();
XXXXXXXXXXtempscore.add("gold"); tempscore.add("potion");
XXXXXXXXXXthem[0]=new Player("Orc", new Weapon("Dagger", 3, 1, 4), new Armor("Chain mail", 12), new Treasure(tempscore), 22, g);
37
XXXXXXXXXXtempscore=new A
ayList
();
XXXXXXXXXXtempscore.add("potion");
XXXXXXXXXXthem[1]=new Player("Nest of snakes", new Weapon("Venom", 1, 4, 20), new Armor("No armor", 0), new Treasure(tempscore), 12, g);
41
XXXXXXXXXXtempscore=new A
ayList
();
XXXXXXXXXXtempscore.add("gold");tempscore.add("silver");tempscore.add("potion");tempscore.add("potion");
XXXXXXXXXXthem[2]=new Player("Troll", new Weapon("Hands", 4, 1, 8), new Armor("Hide", 14), new Treasure(tempscore), 25, g);
45
XXXXXXXXXXtempscore=new A
ayList
();
XXXXXXXXXXtempscore.add("silver");tempscore.add("potion");
XXXXXXXXXXthem[3]=new Player("Beserker", new Weapon("Sword", 4, 1, 4), new Armor("Shield", 2), new Treasure(tempscore), 28, g);
49
XXXXXXXXXXtempscore=new A
ayList
();
XXXXXXXXXXtempscore.add("potion");tempscore.add("potion");tempscore.add("scroll");
XXXXXXXXXXthem[4]=new Player("Ninja", new Weapon("Super sword", 4, 2, 8), new Armor("Chain mail", 14), new Treasure(tempscore), 40, g);
53
XXXXXXXXXXtempscore=new A
ayList
();
XXXXXXXXXXtempscore.add("gold");tempscore.add("silver");tempscore.add("silver");tempscore.add("silver");tempscore.add("scroll");
XXXXXXXXXXthem[5]=new Player("Dragon", new Weapon("Claws", 2, 11, 20), new Armor("Skin", 14), new Treasure(tempscore), 25, g);
XXXXXXXXXXtempscore=new A
ayList
();
XXXXXXXXXXtempscore.add("gold");tempscore.add("gold");tempscore.add("gold");
XXXXXXXXXXthem[7]=new Player("Wizard", new Weapon("Lightning bolts", 1, 21, 40), new Armor("Magic aura", 15), new Treasure(tempscore), 150, g);
64
ready for first fight against them[0], set option to be 5 to start the fight
XXXXXXXXXXint n=0, option=5;
n is which Player you are about to face, option is the user's option in a menu listed between fights
66
67
while(user.isAlive()&&
68
XXXXXXXXXXwhile(n<8&&option!=4)
continue while user is still alive, has not won the game and has not quit
70 {
XXXXXXXXXXif(n==6)
create them[6], the dopplegange
72
them[6]=new Player("Doppleganger", user.getWeapon(), user.getArmor1(), user.getTreasure(),user.getHitPoints(), g);
XXXXXXXXXXuser.fight(them[n]);
user fights nth Playe
74
if(user.isAlive())
if user wins
75
{
76
user.takeWeapon(them[n].getWeapon());
test to see if opponent's weapon, armor1 or armor2 are takeable and bette
77
user.takeArmor(them[n].getArmor1());
than user's
78
if(them[n].getArmor2()!=null) user.takeArmor(them[n].getArmor2());
XXXXXXXXXXuser.getTreasure().addTreasure(them[n].getTreasure().getTreasure());
obtain opponent's treasure
XXXXXXXXXXSystem.out.println("Your status: " + user);
output user as it now is
XXXXXXXXXXrested=false;
user is allowed to rest once between fights
XXXXXXXXXXdo{
allow user to rest, use scrolls, potions or quit as desired
XXXXXXXXXXoption=menu(in);
XXXXXXXXXXif(option==1&&!rested)
can only rest once
85 {
86 {
87 XXXXXXXXXXSystem.out.println("User's rest is inte
upted, get ready to fight!");
88 XXXXXXXXXXoption=5;
force user to fight when inte
upted
89 }
9 XXXXXXXXXXrested=true;
rested once, cannot rest again this turn
91 }
XXXXXXXXXXelse if(option==1) System.out.println("You cannot rest again during this turn");
93
else if(option==2) user.usePotion();
94
else if(option==3) user.useScroll();
95 }while(option!=4&&option!=5);
96
&&user.isAlive());
XXXXXXXXXXif(option!=4) n++;
98
}
99 }
output result of game
100
if(n<8&&user.isAlive())
XXXXXXXXXXSystem.out.println("Running away, ? You successfully defeated " + n + " fighters with " + user.getTreasure());
XXXXXXXXXXif(n==8) System.out.println("Congratulations, you win!!! You end the game with " + user.getTreasure());
XXXXXXXXXXelse System.out.println("I'm so
y, you died after defeating only " + n + " fighters, with " + user.getTreasure());
104
105 }
106
107
method to obtain user input
108 public static int menu(Scanner s)
109 {
XXXXXXXXXXint tempscore;
XXXXXXXXXXdo
112 {
XXXXXXXXXXSystem.out.println("What do you want to do next? \n1. Rest