forked from League-Archive/IntroToJavaWorkshop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDragonFight.java
More file actions
65 lines (33 loc) · 2.14 KB
/
DragonFight.java
File metadata and controls
65 lines (33 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package section4;
import java.util.Random;
import javax.swing.JOptionPane;
import javax.swing.ImageIcon;
public class DragonFight {
// 1. Put all of the game code inside the main method (below)
public static void main(String[] args) {
ImageIcon dragon = new ImageIcon("src/section4/dragonPicture.jpg");
JOptionPane.showMessageDialog(null, "Defeat the dragon to take its treasure!", "Dragon Fighter", 0, dragon);
// 2. Create a variable called "playerHealth" to store your health (set it equal to 100)
// 3. Create a variable called "dragonHealth" to store the dragon's health (set it equal to 100)
// 4. Create a variable to hold the damage the player's attack does each round
// 5. Create a variable to hold the damage the dragon's attack does each round
// 6. Delete the slashes at the beginning of the next line.
//while(playerHealth>0 && dragonHealth>0) { //this line of code keeps the battle going until someone's health reaches 0
// 7. Add a closing mustache at the very bottom of this program (since we just added an opening mustache on the previous step).
// 8. Ask the player in a pop-up if they want to attack the dragon with a yell or a kick
// 9. If they typed in "yell":
//-- Find a random number between 0 and 10 and store it in dragonDamage
//-- Subtract that number from the dragon's health variable
// 10. If they typed in "kick":
//-- Find a random number between 0 and 25 and store it in dragonDamage
//-- Subtract that number from the dragon's health variable
// 11. Find a random number between 0 and 35 and store it in playerDamage
// 12. Subtract this number from the player's health
// 13. If the user's health is less than or equal to 0
//-- Tell the user that they lost
// 14. Else if the dragon's health is less than or equal to 0
//-- Tell the user that the dragon is dead and they took a ton of gold!
// 15. Else
//-- Pop up a message that tells the their current health and the dragon's currently health (Bonus: Also display the amount of health that was lost for each player this round)
}
}