
Новые сообщения [новые:0]
Дайджест
Горячие темы
Избранное [новые:0]
Форумы
Пользователи
Статистика
Статистика нагрузки
Мод. лог
Поиск
|
|
15.12.2012, 03:20:43
|
|||
|---|---|---|---|
|
|||
Игра Виселица в java |
|||
|
#18+
Не могли бы помочь найти ошибку... public class Bsp09 { static String[][] hangman = { { "----- ", "| | ", "| ", "| ", "| ", "| ", }, { "----- ", "| | ", "| o ", "| ", "| ", "| ", }, { "----- ", "| | ", "| o ", "| | ", "| ", "| ", }, { "----- ", "| | ", "| o ", "| -| ", "| ", "| ", }, { "----- ", "| | ", "| o ", "| -|-", "| ", "| ", }, { "----- ", "| | ", "| o ", "| -|-", "| / ", "| ", } }; static String[] loosehangman = { "----- ", "| | ", "| @ ", "| -|-", "| / \\", "| ", }; static String[] winhangman = { " ", " \\o/", " | ", " / \\", " ", }; static String[] words = { "praiseworthy", "perspiration", "propitiatory", "broadcasting", "irrelevantly", "quantitative", "boondoggling", "considerings", "tobacconists", "formlessness", "undetermined", "relinquished", "condescended", "intoxicating", "disorganizes", "hydrocarbons", "consultation", "deceleration", "sandblasting", "infestations", "rebelliously", "manifestoing", "pettifogging", "breastplates", "discourteous", "prospectives", "unflattering", "headmistress", "administrate", "immoderately" }; public static void main(String[] args) { int i = 0; String wort = ""; i = (int) (Math.random() * (words.length - 1)); wort = words[i]; int n = wort.length(); String[] b = new String[n]; // массив куда записываем ответы for (int j = 0; j < n; j++) b[j] = "_"; int anz = 0; // Anzahl der Buchstaben int m = 0; // nummers von Bilder int p = 0; // nummers drinnen String versuch = ""; do { for (p = 0; p < hangman.length; p++) System.out.println(hangman[m][p]); System.out.print("Guess this word:"); for (int j = 0; j < n; j++) System.out.print(b[j]); System.out.println(); System.out.println("Characters tried:" + versuch); System.out.println("Give a letter please:"); char x; x = SavitchIn.readChar(); versuch = versuch + String.valueOf(x); int h; int a = 0; for (h = 0; h < n; h++) { if (x == wort.charAt(h)) { b[h] = String.valueOf(x); anz++; a++; System.out.println("m=" + m); } } if (a == 0) m++; if (anz == n) { for (int l = 0; l < winhangman.length; l++) System.out.println(winhangman[l]); break; } System.out.println("m=" + m); x = 0; } while (m < hangman.length); if (anz != n) { for (int l = 0; l < loosehangman.length; l++) System.out.println(loosehangman[l]); } } } выдает ---- | | | | | | Guess this word:____________ Characters tried: Give a letter please: a m=0 ----- | | | | | | Guess this word:_______a____ Characters tried:a Give a letter please: m=1 ----- | | | o | | | Guess this word:_______a____ Characters tried:a Give a letter please: m=2 ----- | | | o | | | | Guess this word:_______a____ Characters tried:a Give a letter please: s m=3 ----- | | | o | -| | | Guess this word:_______a____ Characters tried:a s Give a letter please: m=4 ----- | | | o | -|- | | Guess this word:_______a____ Characters tried:a s Give a letter please: m=5 ----- | | | o | -|- | / | Guess this word:_______a____ Characters tried:a ... |
|||
|
:
Нравится:
Не нравится:
|
|||
|
|
|

start [/forum/topic.php?fid=59&mobile=1&tid=2130358]: |
0ms |
get settings: |
15ms |
get forum list: |
25ms |
check forum access: |
7ms |
check topic access: |
7ms |
track hit: |
54ms |
get topic data: |
21ms |
get forum data: |
5ms |
get page messages: |
55ms |
get tp. blocked users: |
2ms |
| others: | 312ms |
| total: | 503ms |

| 0 / 0 |
