- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
class game {
public static void main (String args[])
throws java.io.IOException {
double x = 0.0;
byte php = 100, mhp = 100, pd = 0, md = 0;
char pd_ch;
boolean b1, b2;
System.out.println("Welcome to \"Kill the mob\" v0.1!");
System.out.println();
System.out.println("While you where wandering in deep dark tunnels, a mob appeared in your way.");
System.out.println("It appeared to be very agressive, so a fight started.");
System.out.println();
do {
System.out.println("Your opponent is ready to act. You need to do something. What are you going to do?");
System.out.print("Enter \"1\" to attack, \"2\" to defend yourself and \"3\" to regenerate: ");
pd_ch = (char) System.in.read();
if (pd_ch == '1')
pd = 1;
else if (pd_ch == '2')
pd = 2;
else
pd = 3;
x = Math.random();
if (x < 0.33333)
md = 1;
else if (x > 0.66666)
md = 3;
else
md = 2;
System.out.println(md);
System.out.println(pd);
switch(pd) {
case 1:
System.out.print("You chose to attack, while mob chose to ");
switch (md) {
case 1:
System.out.println("attack too!");
System.out.println("You both lose 20 HP.");
php -= 20;
mhp -= 20;
break;
case 2:
System.out.println("defend.");
System.out.println("You did not manage to hurt him.");
break;
case 3:
System.out.println("regenerate.");
System.out.println("He lost 30 HP.");
mhp -= 30;
break;
}
break;
case 2:
System.out.print("You chose to defend, while mob chose to ");
switch (md) {
case 1:
System.out.println("attack.");
System.out.println("You did not let him hurt you.");
break;
case 2:
System.out.println("defend too!");
System.out.println("You standed like two retards.");
break;
case 3:
System.out.println("regenerate.");
System.out.println("He gained 20 HP.");
mhp += 20;
break;
}
break;
case 3:
System.out.print("You chose to regenerate, while mob chose to ");
switch (md) {
case 1:
System.out.println("attack.");
System.out.println("You was completely protectless. you you've lost 30 HP.");
php -= 30;
break;
case 2:
System.out.println("defend.");
System.out.println("He standed like a retard, while you gained 20 HP.");
php += 20;
break;
case 3:
System.out.println("regenerate too!");
System.out.println("Your energies helped each other, so you both gained 30 HP.");
mhp += 30;
php += 30;
break;
}
break;
}
System.out.println("Your HP: " + php);
Цикл после одного ввода делается какого-то хуя 3 раза, причем с рандомными (1, 2, 3) pd и md. ЧЯДНТ?
Denis Popov 10.08.2010 18:35 # +2
xXx_totalwar 10.08.2010 18:45 # +3
где абстрактные фабрики абстрактных адаптеров фабрик адаптеров?
Анонимус 10.08.2010 18:50 # +3
Кстати, где GOTO?
Без GOTO нынче писать не модно
Lure Of Chaos 10.08.2010 21:09 # 0
Kill the mob, shoot urself