Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
6040879
Add files via upload
mputzer1 Apr 16, 2024
592d3a6
Biome Classes
mputzer1 Apr 16, 2024
1888406
Added plants!
mputzer1 Apr 16, 2024
2e07d67
FloraFauna
mputzer1 Apr 16, 2024
fca37b1
They speak!
mputzer1 Apr 16, 2024
7c1a1cf
Push to tester branch
mputzer1 Apr 16, 2024
889d0c5
.java
mputzer1 Apr 18, 2024
cd6be95
Added welcome and riddle methods to rainforest
mputzer1 Apr 18, 2024
0a8c1d8
Updated classes
mputzer1 Apr 18, 2024
0c66294
(4/18)
mputzer1 Apr 18, 2024
97c245e
Room Connections Built
mputzer1 Apr 19, 2024
0ee2a2d
More location testing
mputzer1 Apr 20, 2024
dff0dc9
Updated to show paths
mputzer1 Apr 21, 2024
2d8b80b
Finished game loop that allows user to move around
mputzer1 Apr 22, 2024
1fe2a16
Start of frog riddle
mputzer1 Apr 22, 2024
a402e45
Updated to String + full game loop
mputzer1 Apr 22, 2024
a18ef9f
Inventory checking
mputzer1 Apr 22, 2024
0a82de6
Checks if inventory is empty
mputzer1 Apr 22, 2024
bec73a5
Modifications to improve paths available and containment of objects
mputzer1 Apr 22, 2024
714c996
Initial consolidation of game loop for rainforest
mputzer1 Apr 23, 2024
f34e699
Updated inventory checker
mputzer1 Apr 24, 2024
4be4ece
Removed monster class
mputzer1 Apr 24, 2024
7221be5
Updated with my riddles
mputzer1 Apr 24, 2024
9cf386f
Updated with javadoc comments for Maura's classes
mputzer1 Apr 24, 2024
001a5e9
Updates with all riddles
mputzer1 Apr 24, 2024
e39e80f
Updated with introduction
mputzer1 Apr 25, 2024
24c9ef1
Lab Class added to consolidate quote
mputzer1 Apr 27, 2024
8d1021f
Consolidated if statements for location
mputzer1 Apr 28, 2024
a0cb4cb
Testing with scoreboard
mputzer1 Apr 29, 2024
fc4c148
Updates to scores
mputzer1 Apr 29, 2024
12289b1
Updated leaderboard
mputzer1 Apr 29, 2024
5ccc98c
Finished leaderboard
mputzer1 Apr 29, 2024
b9700bc
Updated username length checker
mputzer1 Apr 30, 2024
c07d0f7
Moved answers to riddles to cheatsheet
mputzer1 Apr 30, 2024
513ccf3
displayimage
abdease May 2, 2024
0b3ac39
graphics
abdease May 2, 2024
6bb358d
reflection and jd comments
abdease May 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"java.project.referencedLibraries": [
"lib/**/*.jar",
"guava-31.1-jre.jar"
]
}
5 changes: 5 additions & 0 deletions AnemoneRiddle.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
In the ocean's sway, I gently hide,
With tendrils waving, a colorful guide.
But beware my touch, for it may chide,
A sea creature's secret, nestled inside.
What am I?
70 changes: 70 additions & 0 deletions Aquatic.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import java.util.Scanner;

/**
* The aquatic class that extends the biome and contains the dolphin and sea anemone
*/
public class Aquatic extends Biome {
private FloraFauna dolphin;
private FloraFauna sea_anemone;
private String imagePath;

/**
* Constructor for aquatic class with information about FloraFauna
*/
public Aquatic() {
super("cs120_lab_image.png");
this.dolphin = new FloraFauna("dolphin", 4, "Dorothy");
this.sea_anemone = new FloraFauna("sea anemone", 5, "Flounder");
this.imagePath = ("ocean.png");
}

/**
* Getter for dolphin
* @return the dolphin object
*/
public FloraFauna getAnimal() {
return this.dolphin;
}

/**
* Getter for anemone
* @return the anemone object
*/
public FloraFauna getPlant() {
return this.sea_anemone;
}

public String getImagePath() {
return imagePath;
}

/**
* Calls riddle method and checks if true or false is returned to determine whether to return dolphin or null.
* @param Scanner s from the game loop class
* @return dolphin object or null
*/
public FloraFauna animalRiddle(Scanner s) {
if (riddle(s, "dolphin", "kraken", "DolphinRiddle.txt")) {
return this.dolphin;
} else {
return null;
}
}

/**
* Calls riddle method and checks if true or false is returned to determine whether to return anemone or null.
* @param Scanner s from the game loop class
* @return sea anemone object or null
*/
public FloraFauna plantRiddle(Scanner s) {
if (riddle(s, "sea anemone", "kraken", "AnemoneRiddle.txt")) {
return this.sea_anemone;
} else {
return null;
}
}

public String toString() {
return "aquatic";
}
}
94 changes: 94 additions & 0 deletions Biome.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import java.util.Scanner;


/**
* Biome class which has the file reader attribute.
*/
public class Biome {
private FileClass FileReader;
private FloraFauna animal;
private FloraFauna plant;
private String imagePath;


/**
* Constructor for biome class
*/
public Biome(String imagePath) {
this.FileReader = new FileClass();
this.animal = new FloraFauna(null, null, null);
this.plant = new FloraFauna(null, null, null);
this.imagePath = imagePath;

}

/**
* Getter for plant
* @return the plant object
*/
public FloraFauna getAnimal() {
return this.animal;
}

/**
* Getter for plant
* @return the plant object
*/
public FloraFauna getPlant() {
return this.plant;
}


public FloraFauna animalRiddle(Scanner s) {
return this.animal;
}


public FloraFauna plantRiddle(Scanner s) {
return this.plant;
}

public String getImagePath() {
return imagePath;
}

/**
* Allows riddles for child classes to be read and answered.
* @param Scanner s that reads user response
* @param String FloraFauna that is riddle subject
* @param String Monster that is attacking user
* @param String filename that is associated with riddle subject
* @return boolean (whether riddle was answered correctly)
*/
public boolean riddle(Scanner s, String FloraFauna, String Monster, String filename) {
System.out.println("");
this.FileReader.fileReader(filename);
String userResponse = "";
int incorrectCounter = 0;
while (true) {
System.out.println("\nEnter your answer:");
userResponse = s.nextLine().toLowerCase();
if (!userResponse.equals(FloraFauna)) {
System.out.println("\nYou've answered incorrectly!");
incorrectCounter += 1;
if (incorrectCounter < 3) {
System.out.println("The " + Monster + " is " + (3 - incorrectCounter) + " feet away.");
}
if (incorrectCounter == 3) {
System.out.println("Your inventory has been eaten!");
return false;
}
}
if (userResponse.equals(FloraFauna)) {
System.out.println("\nYou've answered correctly! The " + FloraFauna + " has been added to your inventory.");
return true;
}
}
}

public String toString() {
return "This is the default biome toString";
}
}


44 changes: 44 additions & 0 deletions BiomeMap.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

import com.google.common.graph.ImmutableValueGraph;
import com.google.common.graph.ValueGraphBuilder;

/**
* Class for a map of the biomes
*/
public class BiomeMap {
private ImmutableValueGraph<String, String> Graph;

/**
* Creates a graph that maps all the biomes and their named connections
*/
public BiomeMap() {
this.Graph = ValueGraphBuilder.directed()
.<String, String>immutable()
.putEdgeValue("rainforest", "aquatic", "east")
.putEdgeValue("aquatic", "rainforest", "west")
.putEdgeValue("rainforest", "desert", "south")
.putEdgeValue("desert", "rainforest", "north")
.putEdgeValue("lab", "rainforest", "northwest")
.putEdgeValue("rainforest", "lab", "southeast")
.putEdgeValue("aquatic", "tundra", "south")
.putEdgeValue("tundra", "aquatic", "north")
.putEdgeValue("lab","aquatic", "northeast")
.putEdgeValue("aquatic", "lab", "southwest")
.putEdgeValue("desert","tundra", "east")
.putEdgeValue("tundra", "desert", "west")
.putEdgeValue("lab", "desert", "southwest")
.putEdgeValue("desert", "lab", "northeast")
.putEdgeValue("lab", "tundra", "southeast")
.putEdgeValue("tundra", "lab", "northwest")
.build();
}

/**
* Getter for the biome map/graph
* @return the biome graph
*/
public ImmutableValueGraph<String, String> getGraph() {
return this.Graph;
}

}
6 changes: 6 additions & 0 deletions CacaoRiddle.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
***RIDDLE***
I am a tree with fruit that's sweet,
My seeds are used for a tasty treat.
I can be made into a bar or a drink,
In many desserts, I'm the missing link.
What am I?
6 changes: 6 additions & 0 deletions CactusRiddle.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
***RIDDLE***
I'm a plant that's tough and spiny,
In the desert, I'm prickly and tiny.
My shape is unique, you cannot mistake,
I can survive in the heat, with very little to take.
What am I?
8 changes: 8 additions & 0 deletions CamelRiddle.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
The sun is low over the horizon and you spot a sea of orange sand in the distance. The wind is harsh and creates swirling sand spires. Dr. Athene hands you a bottle with a strange message...

***RIDDLE***
I am an animal with a hump,
In the desert, I can easily jump.
I store water in my body and can go days without,
My feet are padded and never wear out.
What am I?
75 changes: 75 additions & 0 deletions Desert.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import java.util.Scanner;

/**
* The desert class that extends the biome and contains the camel and cactus
*/
public class Desert extends Biome {
private FloraFauna camel;
private FloraFauna cactus;
private String imagePath;


/**
* Constructor for desert class with information about FloraFauna
*/
public Desert() {
super("cs120_lab_image.png");
this.camel = new FloraFauna("camel", 2, "Tom");
this.cactus = new FloraFauna("cactus", 3, "Janice");
this.imagePath = "desert.png";

}

/**
* Getter for camel
* @return the camel object
*/
public FloraFauna getAnimal() {
return this.camel;
}

/**
* Getter for cactus
* @return the cactus object
*/
public FloraFauna getPlant() {
return this.cactus;
}

public String getImagePath() {
return imagePath;
}



/**
* Calls riddle method and checks if true or false is returned to determine whether to return camel or null.
* @param Scanner s from the game loop class
* @return camel object or null
*/
public FloraFauna animalRiddle(Scanner s) {
if (riddle(s, "camel", "sharknado", "CamelRiddle.txt")) {
return this.camel;
} else {
return null;
}
}

/**
* Calls riddle method and checks if true or false is returned to determine whether to return cactus or null.
* @param Scanner s from the game loop class
* @return cactus object or null
*/
public FloraFauna plantRiddle(Scanner s) {
if (riddle(s, "cactus", "sharknado", "CactusRiddle.txt")) {
return this.cactus;
} else {
return null;
}
}

public String toString() {
return "desert";
}

}
40 changes: 40 additions & 0 deletions DisplayImage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import javax.swing.*;
import java.awt.*;
/*
* class to implement graphics for lab and biomes
*/
public class DisplayImage extends JFrame {

private JLabel label;

public DisplayImage() {
setTitle("Image Display");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(400, 400);

label = new JLabel();

getContentPane().add(label, BorderLayout.CENTER);

/*
* sets initial image for start of game (lab image)
*/
ImageIcon initialIcon = new ImageIcon("cs120_lab_image.png");
label.setIcon(initialIcon);
}
/*
* method to update image as game progresses through biomes
* @param imagePath
*/
public void updateImage(String imagePath) {
ImageIcon icon = new ImageIcon(imagePath);
label.setIcon(icon);
}

public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
DisplayImage imageDisplay = new DisplayImage();
imageDisplay.setVisible(true);
});
}
}
6 changes: 6 additions & 0 deletions DolphinRiddle.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
***RIDDLE***
Beneath the waves, I gracefully roam,
A mammal in waters, I call my home.
With echolocation, I navigate,
In ocean's vastness, I dominate.
What am I?
6 changes: 6 additions & 0 deletions FernRiddle.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
***RIDDLE***
In shadows deep, I unfurl my fronts,
A relic of ancient, verdant bonds.
Through spores I spread, my lineage profound,
A symbol of resilience, forever unbound.
What am I?
Loading