Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- import java.util.Scanner;
- public class Camel {
- public static void main(String[] args) {
- Scanner userInput = new Scanner(System.in);
- Random rand = new Random();
- System.out.println("Welcome to the Camel Game!");
- System.out.println("You have stolen a camel and must escape over the Gobi desert into Mongolia while a tribe hunts you down!");
- System.out.println("You must stay ahead of the tribe while keeping your self hydrated and keep your camel dying from exhaustion. ");
- /* Program Calculations */
- int userDistance = 20;
- int tribeDistance = 0;
- double thirst = 0;
- int camelTiredness = 0;
- int water = 3;
- while (true) {
- int oasis = 1 + rand.nextInt(20);
- /* User inputs */
- System.out.println("\r\n");
- System.out.println("A) Move at a fast pace.");
- System.out.println("B) Move at a moderate pace.");
- System.out.println("C) Drink a litre of water.");
- System.out.println("D) Rest for the day");
- System.out.println("E) Status.");
- System.out.println("F) Quit");
- System.out.println("Enter command: ");
- String userCommand = userInput.next();
- int rngtribeFas = 10 + rand.nextInt(20);
- if (userCommand.toUpperCase().equals("A")) {
- System.out.println("You move at a fast pace.");
- int rnguserFas = 15 + rand.nextInt(25);
- userDistance += rnguserFas;
- tribeDistance += rngtribeFas;
- thirst += 1;
- camelTiredness += 2;
- System.out.format("You travel %d kilometres.", rnguserFas);
- } else if (userCommand.toUpperCase().equals("B")) {
- System.out.println("You move at a moderate pace");
- int rngMod = 7 + rand.nextInt(15);
- userDistance += rngMod;
- tribeDistance += rngtribeFas;
- thirst += 0.5;
- camelTiredness += 1;
- System.out.format("You travel %d kilometres.", rngMod);
- } else if (userCommand.toUpperCase().equals("C")) {
- if (water > 0) {
- System.out.println("You drink a litre of water.");
- water -= 1;
- thirst = 0;
- }
- else{
- System.out.println("You have no water left!");
- }
- } else if (userCommand.toUpperCase().equals("D")) {
- System.out.println("You and the camel rest");
- tribeDistance += rngtribeFas;
- camelTiredness = 0;
- } else if (userCommand.toUpperCase().equals("E")) {
- System.out.format("You have traveled %d miles, the tribe is %d behind you, and you have %d litres of water remaining.", userDistance, userDistance - tribeDistance, water);
- } else if (userCommand.toUpperCase().equals("F")) {
- break;
- } else {
- System.out.println("Unknown input");
- }
- if (userDistance == 500) {
- System.out.println("You escaped into mongolia and survived!");
- System.out.println("GAME OVER");
- break;
- } else if (tribeDistance >= userDistance) {
- System.out.println("You've been captured by the tribe!");
- System.out.println("GAME OVER");
- break;
- }
- else if (tribeDistance == userDistance - 20) {
- System.out.println("The tribe is getting close!");
- }
- if (thirst >= 3 && thirst <= 6) {
- System.out.println("You are thirsty.");
- } else if (thirst >= 8) {
- System.out.println("Have you died from thirst!");
- System.out.println("GAME OVER!");
- break;
- }
- if (camelTiredness >= 4 && camelTiredness <= 7) {
- System.out.println("Your camel is tired.");
- } else if (camelTiredness >= 8) {
- System.out.println("Your camel has died from exhaustion! The tribe has caught you!");
- System.out.println("GAME OVER!");
- break;
- }
- if (oasis == 20) {
- System.out.println("You found an oasis! You've drunk your fill, refilled your canteen and rested the camel!");
- water = 3;
- thirst = 0;
- camelTiredness = 0;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement