Java'da yaptığım bulmaca oyunu

William Crusader

Hectopat
Katılım
11 Kasım 2020
Mesajlar
5.371
Makaleler
1
Çözümler
14
Daha fazla  
Cinsiyet
Erkek
Meslek
Yok
Phyton'la başladık şimdi neredeyiz :)
@The Towande

Oyundaki 4 thane başarımı açmak için farklı kombinasyonlar denemeniz gerekiyor. 4 başarımı da almayı başarırsanız oyunu kazanıyorsunuz.

Kod:
[CODE lang="java" title="Java"]package mainWork;
import javax.swing.JOptionPane;

public class MainWork {


public static void main(String[] args) {
int right = 0;
int left = 0;
int forward = 0;
int achcount = 0;
boolean loop = false;
boolean google = false;
boolean wall = false;
boolean hell = false;


boolean restart = true;

while(restart == true){
String movement = JOptionPane.showInputDialog("Welcome to my puzzle game.\nIn this game, you try to find the combination of movements to get all 4 achievements.\nYou can go /left, /right, /forward, /backward, or use /achievements to see how much achievements you have.\nYou can also reset the values by typing /reset.\n(backward will just make the forward less) \nLeft: " + left + "\nRight: " + right + "\nForward: " + forward);
movement = movement.toLowerCase();

if(movement.equals("/right")) {
right = goright(right);
}

else if(movement.equals("/left")) {
left = goleft(left);
}

else if(movement.equals("/forward")) {
forward = goforward(forward);
}

else if(movement.equals("/backward")) {
forward = gobackward(forward);
}

else if(movement.equals("/achievements")) {
JOptionPane.showMessageDialog(null, "Your achievements: "+ achcount);
}

else if(movement.equals("/reset")) {
right = 0;
left = 0;
forward = 0;
}

else {
JOptionPane.showMessageDialog(null, "ERROR!!");
}

if (right >= 12) {
if(loop == false) {
JOptionPane.showMessageDialog(null, "You got \"I am Right!\" achievement!");
right = right - 12;
achcount = achcount + 1;
loop = true;
}
}

else if (left >= 19 && right >= 9 && forward >= 8) {
if(google == false) {
JOptionPane.showMessageDialog(null, "You got \"Google achievement!\"");
right = right - 19;
left = left - 9;
forward = forward - 8;
achcount = achcount + 1;
google = true;
}
}

else if (forward <= -1) {
if(wall == false) {
JOptionPane.showMessageDialog(null, "You got \"bunk to the wall\" achievement!");
forward = 0;
achcount = achcount + 1;
wall = true;
}
}

else if (right == 6 && left == 6 && forward == 6) {
if(hell == false) {
JOptionPane.showMessageDialog(null, "You got \"THE HELL\" achievement!");
right = 0;
left = 0;
forward = 0;
achcount = achcount + 1;
hell = true;
}
}

if (achcount == 4) {
restart = false;
JOptionPane.showMessageDialog(null, "Congratulations, you got all 4 achievements! \nWhat now? What happened when you got all 6 of them?\nYou literally wasted your time into this trash game? Really?");
}
}
}

static int goright(int right) {
right = right + 1;
return right;
}

static int goleft(int left) {
left = left + 1;
return left;
}

static int goforward(int forward) {
forward = forward + 1;
return forward;
}

static int gobackward(int forward) {
forward = forward - 1;
return forward;
}
}[/CODE]
 

Bu konuyu görüntüleyen kullanıcılar

Technopat Haberler

Yeni konular

Geri
Yukarı