diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..c995aa5c --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.debug.settings.onBuildFailureProceed": true +} \ No newline at end of file diff --git a/Castle.java b/Castle.java new file mode 100644 index 00000000..7fbbe91c --- /dev/null +++ b/Castle.java @@ -0,0 +1,56 @@ +public class Castle { + protected String name; + protected boolean isAccessible; + protected boolean isInTheCastle; + + public Castle(String name) { + this.name = name; + this.isAccessible = true; + this.isInTheCastle = false; + } + + public String getName() { + return name; + } + + public boolean isAccessible() { + return isAccessible; + } + + public void setAccessible(boolean accessible) { + this.isAccessible = accessible; + } + + public boolean isInTheCastle() { + return isInTheCastle; + } + + // Aliases for entering and exiting the castle + public void enter() { + goUp(); + } + + public void exit() { + goDown(); + } + + public void goUp() { + if (isAccessible && !isInTheCastle) { + isInTheCastle = true; + System.out.println("You have entered the " + name + "."); + } else if (isInTheCastle) { + System.out.println("You are already in the " + name + "."); + } else { + System.out.println("The " + name + " is not accessible right now."); + } + } + + public void goDown() { + if (isInTheCastle) { + isInTheCastle = false; + System.out.println("You have exited the " + name + "."); + } else { + System.out.println("You are not in the " + name + " to exit."); + } + } +} diff --git a/FullSpinner.java b/FullSpinner.java new file mode 100644 index 00000000..f3714366 --- /dev/null +++ b/FullSpinner.java @@ -0,0 +1,54 @@ +import java.util.ArrayList; +import java.util.Random; + +public class FullSpinner { + private ArrayList parts; + + public FullSpinner(){ + this.parts = new ArrayList<>(); + } + + +public void addParts(){ + parts.add(new SpinnerPart("Red")); + parts.add(new SpinnerPart("Purple")); + parts.add(new SpinnerPart("Yellow")); + parts.add(new SpinnerPart("Blue")); + parts.add(new SpinnerPart("Orange")); + parts.add(new SpinnerPart("Green")); + + //adding my candies + + parts.add(new SpinnerPart("Ice cream")); + parts.add(new SpinnerPart("Peanut")); + parts.add(new SpinnerPart("Lollipop")); + parts.add(new SpinnerPart("Licorice")); + + +} +//i'll need to add an override method to a to string + +// @Override +// public void toString(){ +// return "FullSpinner has a "; +// } + +public String spin(){ + int Index = random.nextInt(parts.size()); //is it not recognizing random? + String part = parts.get(Index).toString(); //can i not use somethig tat is part of a method in another class + return part ;//the thing that + //how could i do this without a getOutput variable + + + // just declare a variable that would pick a random number from the number of stuff in the arraylist + //and then just get it to spit out that index + + +} +public static void main(String[] args) { + FullSpinner spinner = new FullSpinner(); + spinner.addParts(); + System.out.println(spinner); +} + +} diff --git a/LicoriceLagoon.java b/LicoriceLagoon.java new file mode 100644 index 00000000..f063a097 --- /dev/null +++ b/LicoriceLagoon.java @@ -0,0 +1,79 @@ +import java.util.ArrayList; +import java.util.Scanner; + + + } + + public int guessNumber(){ + return this.selectNumber; + /* + * When you land in the lagoon you will need to guess a number from 1 to 10. + * If you guess it incorectly, you will get a random trivia question. + * Array List of the trivia questions. + */ + } + + public Boolean proceedTrivia(){ + /* + * If number guessed is incorrect proceed to trivia questions. + */ + return this.trivia; + } + + public String triviaQuestions(){ + /* + * Random questions in an Array List + */ + questions = new ArrayList<>(); + + return this.triviaQuestions; + } + + public String proceedOrNot(){ + /* + * If trivia questions wrongly answered then player loses + and therefore proceeds through the long way and does not get directly + relocated to were the catsles are. + * If correctly answered then player gets relocated to the first castle. + */ + return this.acceptance; + + public class LicoriceLagoon extends PathPlaces{ + + public LicoriceLagoon(String name, int playerInput, ArrayList triviaQuestions) { + super (name, playerInput, triviaQuestions); + } + public void printPathName() { + /* + * When you land in the lagoon you will need to guess a number. + * If you guess it incorectly, you will get a random trivia question. + * ArrayList of the trivia questions. + */ + System.out.println("You have entered the Licorice Lagoon! You are ready to begin your next challenge. From 2000 - 5000, how many licorice make up the Lagoon?"); + + Scanner scanner = new Scanner(System.in); + int playerInput = scanner.nextInt(); + System.out.println(triviaQuestions.size()); + String question = triviaQuestions.get(this.random.nextInt (triviaQuestions.size())); + + if (playerInput >= 2000 && playerInput <= 5000) { + if (playerInput % 2 != 0) { + System.out.println("Aha! I see you have done your research! " + playerInput + " licorice make up the Lagoon. You can advance to the next tile."); + } else { + System.out.println("Oh no! " + playerInput + " is not the correct number of licorice that make up the Lagoon. You must complete the following trivia question to move to the next tile." + question); + + System.out.println("Well done! You have completed the challenge and may progress to the next tile."); + } + } else { + throw new IllegalArgumentException("Please enter a number between 2000 and 5000."); + } + + } + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + +} + LicoriceLagoon llTest = new LicoriceLagoon("Licorice Lagoon", 2003, PathPlaces.triviaQuestions); + llTest.printPathName(); + } + } \ No newline at end of file diff --git a/LollipopCastle.java b/LollipopCastle.java new file mode 100644 index 00000000..141f4c9b --- /dev/null +++ b/LollipopCastle.java @@ -0,0 +1,29 @@ +public class LollipopCastle extends Castle { + private int jumpAttempts; + + public LollipopCastle() { + super("Lollipop Castle"); + this.jumpAttempts = 2; // Number of chances the player has to jump correctly + } + + public boolean jumpChallenge(int height) { + /* + * Logic: + * - If height is within the safe range (e.g., 5 to 10), the jump is successful. + * - If height is too low (e.g., < 5), the player falls short and "dies". + * - If height is too high (e.g., > 10), the player hits something and "dies". + * - Allow the player up to 'jumpAttempts' to get it right. + */ + + // Placeholder return for now — actual logic to be implemented + return false; + } + + public int getJumpAttempts() { + return jumpAttempts; + } + + public void resetJumpAttempts() { + this.jumpAttempts = 2; //to reset when retrying + } +} diff --git a/Map.java b/Map.java new file mode 100644 index 00000000..303d52e7 --- /dev/null +++ b/Map.java @@ -0,0 +1,109 @@ +import java.util.ArrayList; + +public class Map { + private Boolean position ; + private String colorBlocks; + private String playerPosition; + + /* Constructor */ + public Map(Boolean position, String colorBlocks, String playerPosition){ + this.position = position; + this.colorBlocks = colorBlocks; + this.playerPosition = playerPosition; + } + + /* + * Index of each block of the map. + */ + public Boolean indexPosition(){ + return this.position; + } + + /* + * Tiles of the map. + */ + public String gameBlocks(){ + return this.colorBlocks; + } + + /* + * Name of the tile (color and index) which the player is in. + */ + public String playerPosition(){ + return this.playerPosition; + } + + /* + * Establishing the player position, color blocks and index position of the tiles in the map. + */ + public void setPlayerPosition(String playerPosition) { + this.playerPosition = playerPosition; + } + + public void setColorBlocks(String colorBlocks) { + this.colorBlocks = colorBlocks; + } + + public void setIndexPosition(Boolean position) { + this.position = position; + } + + public static void main(String[] args){ + /* + * Map array list. + */ + ArrayList map = new ArrayList<>(); + FullSpinner spinner = new FullSpinner(); + spinner.addParts(); + /* + * Setting the colors of the tiles. + */ + String[] colors = {"Red", "Purple", "Yellow", "Blue", "Orange", "Green"}; + + /* + * Loop for the map and tiles. + */ + for (int i = 0; i < 61; i++){ + String color = colors[i % colors.length]; + Map tiles = new Map(false, color, "None"); + map.add(tiles); + } + + /* + * Position and index gets set in the map. + */ + map.get(playerIndex).setIndexPosition(true); + map.get(playerIndex).setPlayerPosition(Player.getName); + + /* + * using the full spinner and spinner parts the color that was randomly selected gets printed. + */ + String spunColor = spinner.spunColor(); + System.out.println("Spinner result: " + spunColor); + + /* + * Array to make the player move to repsective tile(color) that was spun in the spinner. + */ + int currentPos = Player.getPosition(); + int newIndex = -1; + for (int i = playerIndex + 1; i < map.size(); i++){ + if (map.get(i).gameBlocks().equalsIgnoreCase(spunColor)){ + newIndex = i; + break; + } + else { + System.out.println("There are no tiles of that color ahead."); + } + /* + * Getting final player position after spinner. + */ + if (newIndex != -1){ + map.get(playerIndex).setIndexPosition(false); + map.get(playerIndex).setPlayerPosition("None"); + map.get(newIndex).setIndexPosition(true); + map.get(newIndex).setPlayerPosition(Player.getName); + playerIndex = newIndex; + System.out.println("Player " + getName + " is now at " + playerIndex); + } + } +} \ No newline at end of file diff --git a/Nana_NutHouse.java b/Nana_NutHouse.java new file mode 100644 index 00000000..2a1be415 --- /dev/null +++ b/Nana_NutHouse.java @@ -0,0 +1,29 @@ +/** + * + */ +import java.util.Scanner; + +public class Nana_NutHouse extends PathPlaces{ + + public Nana_NutHouse(String name, int playerInput) { + super (name, playerInput); + } + + public int chocoBridgeNumber() { + if (playerInput % 2 != 0) { + System.out.println("Congratulations! Your magic number " + playerInput + " has unlocked the chocolate bridge. You advance to Licorice Lagoon!"); + } else { + System.out.println("Oh no! Your number " + playerInput + " has broken the chocolate bridge! You will have to take the long way after you answer this trivia question. Best of luck!"); + String question = triviaQuestions.get(this.random.nextInt (triviaQuestions.size())); + System.out.println("Well done! You have completed the challenge and may progress to the next tile."); + } + return this.playerInput; + } + + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + + Nana_NutHouse nanasTest = new Nana_NutHouse("Nana's House", 6); + nanasTest.chocoBridgeNumber(); + } +} diff --git a/PathPlaces.java b/PathPlaces.java new file mode 100644 index 00000000..e09b00d1 --- /dev/null +++ b/PathPlaces.java @@ -0,0 +1,57 @@ +/** + * PathPlaces is the base class that each Peppermint Forest, Licorice Lagoon, and Nana's Nut House inherit from in this game. + * Each location, or Path Place, has a name and a number guessing challenge. If correct the player proceeds and if incorrect, the player must answer a trivia question stored in triviaQuestions. The player will then proceed upon answering the question. + * The following imports, a scanner and an arraylist are necessary for PathPlaces. +*/ + +import java.util.ArrayList; +import java.util.Random; +import java.util.Scanner; +/** + * The following attributes are for Path Places and each subclass; Peppermint Forest, Nana's Nut House, and Licorice Lagoon. The trivia questions are stored in an Array List. +*/ + +public class PathPlaces { + protected String name; + protected int playerInput; + protected ArrayList triviaQuestions; + protected Random random; +/** + * The following constructor includes these paramenters: + * @param name + * @param playerInput + */ +public PathPlaces(String name, int playerInput) { + this.name = name; + this.playerInput = playerInput; + this.triviaQuestions = new ArrayList<>(); + this.random = new Random(); +} +/** + * printPathName will print the name of each subclass. + * getPathName obtains the name of the subclass. + * addString are the questions stored in the array list triviaQuestions. Initially a hashtable was going to be used, but for simplicity purposes an array list seemed to work better at this time. + */ +public void printPathName() { + System.out.println("Welcome to " + this.name + "!"); +} + +public String getPathName() { + return this.name; +} +/* +* Random questions in an Array List +*/ +public void addString(String str) { + this.triviaQuestions.add("What is the one secret to Nana's bizcocho recipe?"); + this.triviaQuestions.add("What is Queen Kandy's favorite color?"); + this.triviaQuestions.add("What animal does Queen Kandy dream of having in her Castle?"); +} +/** + * Main Method + * @param args + */ +public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); +} +} \ No newline at end of file diff --git a/PeppermintForest.java b/PeppermintForest.java new file mode 100644 index 00000000..ed1c1557 --- /dev/null +++ b/PeppermintForest.java @@ -0,0 +1,37 @@ +import java.util.ArrayList; +import java.util.Scanner; + +public class PeppermintForest extends PathPlaces{ + + public PeppermintForest(String name, int playerInput) { + super(name, playerInput); + } + + public void printPathName() { + System.out.println("You have entered the Peppermint Forest! With the aroma of peppermint candy canes, mint chocolate chip, and sugar, you are ready to begin your first challenge. From 1 - 10000, how many peppermint candy canes make up the Peppermint Forest?"); + + Scanner scanner = new Scanner(System.in); + int playerInput = scanner.nextInt(); +/* +* If trivia questions wrongly answered then player loses and therefore proceeds through the long way and does not get directly relocated to were the catsles are. +* If correctly answered then player gets relocated to the first castle. +*/ + if (playerInput >= 1 && playerInput <= 10000) { + if (playerInput % 2 != 0) { + System.out.println("Way to go! Exactly " + playerInput + " peppermint candy canes make up the Peppermint Forest! You can advance to the next tile. Remember to grab a candy cane on your way out."); + } else { + System.out.println("Unfortunately " + playerInput + " is not the correct amount of peppermint candy canes that make up the Peppermint Forest. You can continue on your path, but you may not take a peppermint candy cane. Good luck!"); + } + } else { + throw new IllegalArgumentException("Please enter a number between 1 and 10000."); + } + } + + } + + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + + PeppermintForest pfTest = new PeppermintForest("PF", 234); + pfTest.printPathName(); + } \ No newline at end of file diff --git a/Player.java b/Player.java new file mode 100644 index 00000000..c2cd8e5b --- /dev/null +++ b/Player.java @@ -0,0 +1,80 @@ +import java.util.ArrayList; +import java.util.Scanner; + + +public class Player { + private String name; + private String color; + private String shape; + private int positionIndex; + private String currPosition; + private int lives; + private Boolean isAlive; + private ArrayList tiles; //only added so i could test my move method , this arraylist should be declared within maybe a tile class or within the map class + + + + + public Player(String name,String color, String shape,int position){ + this.name = name ; + this.currPosition = "red";//if we have all the points on the map that the player can be at set up as an arraylist then im setting this to 0 as statring position + this.positionIndex = 0; + this.lives = 3; + this.isAlive = true; + this.tiles = new ArrayList<>(); + } + + public String enterName(){ + Scanner sc = new Scanner(System.in); + System.out.println("Enter your name:"); + String name = sc.nextLine(); + return name; + + } + + + public String getName(){ + return name; + } + + public int getPositionIndex(){ + return positionIndex; + } + + public void setPositionIndex(int positionIndex){ + this.positionIndex=positionIndex;//setter cause this is the only one we need to manipulate + } + //have a move method - while loop + + + + public String getCurrPosition() { + return currPosition; + } + + public void move(String SpinnerPart, ArrayList tiles){ + this.positionIndex+=1; / + if (this.positionIndex >= tiles.size()) { + this.positionIndex = tiles.size() - 1; + } + + while(this.positionIndex < tiles.size() && !tiles.get(this.positionIndex).equals(SpinnerPart)){//this just checks if the color of the tile tjat we are on is the same as the out put of our spinner and if it isn't, then the player keeps moving one tile forward + this.positionIndex+=1; + } + this.currPosition = SpinnerPart; + } + + + + + + + + + + + + + +} + diff --git a/QueenKandyCastle.java b/QueenKandyCastle.java new file mode 100644 index 00000000..a7d2b8ea --- /dev/null +++ b/QueenKandyCastle.java @@ -0,0 +1,14 @@ +public class QueenKandyCastle extends Castle { + + // Constructor + public QueenKandyCastle() { + super("Queen Kandy's Castle"); + } + + // Method to start final challenge (or ending) + public void startChallenge() { + // 1. Print final success message + System.out.println("🎉 Congratulations! You’ve reached Queen Kandy’s Castle."); + System.out.println("🏰 YOU WIN! YOU MADE IT TO THE END OF THE GAME! 🎉"); + } +} diff --git a/SpinnerPart.java b/SpinnerPart.java new file mode 100644 index 00000000..ed18635c --- /dev/null +++ b/SpinnerPart.java @@ -0,0 +1,45 @@ +import java.util.ArrayList; + + +public class SpinnerPart { + //text based version of the spinner + // private output; + //this could be a string or an int - and i need to remember the abstraction way to fix that + // private ArrayList Parts; + private String Item; + private String Color; + + + //initialize the constructor + // public Spinner(ArrayList Parts){ + // this.Parts = new ArrayList<>(); + // } +//overloading + public SpinnerPart(String Color) { + this.Color = Color; +} + public SpinnerPart(String Color, String Item) { + this.Color = Color; + this.Item = Item; + } + + public String getColor(){ + return Color; + } + + + + public String getItem(){ + return Item; + } + + + + + + +} + + + + diff --git a/architechture diagram.png b/architechture diagram.png new file mode 100644 index 00000000..0abb5e77 Binary files /dev/null and b/architechture diagram.png differ diff --git a/frostedPalace.java b/frostedPalace.java new file mode 100644 index 00000000..c1ccb6d1 --- /dev/null +++ b/frostedPalace.java @@ -0,0 +1,45 @@ +public class frostedPalace extends Castle { + + // Attributes + private int correctNumber; // Number player must guess + private int temperature; // Current temperature + private boolean isAlive; // Player's survival status + + // Constructor + public frostedPalace() { + super("Frosted Palace"); + // initialize correctNumber, temperature, isAlive + } + + // Methods + + // Starts the challenge in Frosted Palace + public void startChallenge() { + // Loop: + // - Ask player to guess + // - Decrease temperature on wrong guess + // - End if guessed correctly or temperature drops too low + } + + // Generates a random number between 1 and 10 + private int generateRandomNumber() { + // Return random number + } + + // Checks if the player is still alive + public boolean getIsAlive() { + // Return survival status + } + + // Returns current temperature + public int getTemperature() { + // Return temperature value + } + + // Optional: Set a freeze threshold (e.g., if temperature <= 0) + private boolean checkFrozen() { + // Return true if player should be considered frozen + } +} + +