Jason's fixes

This commit is contained in:
nicoagostini committed 2025-09-22 14:00:33 -07:00
commit 56a200dd04
11 files changed
+109 -22

No files matched your search

@@ -7,7 +7,8 @@ package ca.bcit.comp2522.lab02;
* @author Braeden Sowinski, Nicolas Agostini, Trishaan Shetty
* @version 1.0.0
*/
public class Creature {
public class Creature
{
private static final int MIN_HEALTH = 1;
private static final int MAX_HEALTH = 100;
private static final int NO_HEALTH = 0;
@@ -158,17 +159,18 @@ public class Creature {
*
* @return details of the creature.
*/
public String getDetails() {
public String getDetails()
{
StringBuilder builder;
builder = new StringBuilder();
builder.append("Is alive: " + this.isAlive());
builder.append("Name: " + this.name);
builder.append("Date of birth: " + this.dateOfBirth);
builder.append("Age: " + this.getAgeYears());
builder.append("Health: " + this.health);
return builder.toString();
}
@@ -8,7 +8,7 @@ package ca.bcit.comp2522.lab02;
* @version 1.0.0
*/
public class DamageException extends RuntimeException {
public DamageException(String message) {
public DamageException(final String message) {
super(message);
}
}
+8 -4
View File
@@ -7,7 +7,8 @@ package ca.bcit.comp2522.lab02;
* @author Braeden Sowinski
* @version 1.0.0
*/
public class Dragon extends Creature {
public class Dragon extends Creature
{
private static final int MAX_FIRE_POWER = 100;
private static final int MIN_FIRE_POWER = 0;
@@ -59,7 +60,8 @@ public class Dragon extends Creature {
* @return details of dragon
*/
@Override
public String getDetails() {
public String getDetails()
{
final StringBuilder builder;
builder = new StringBuilder();
@@ -85,7 +87,8 @@ public class Dragon extends Creature {
* @throws RuntimeException if the dragon is not alive to accomplish the action
*/
public void breatheFire(final Creature target)
throws LowFirePowerException, RuntimeException {
throws LowFirePowerException, RuntimeException
{
if (!this.isAlive()) {
throw new RuntimeException("The dragon is not alive.");
@@ -107,7 +110,8 @@ public class Dragon extends Creature {
*
* @param amount to increase firePower
*/
protected void restoreFirePower(final int amount) {
protected void restoreFirePower(final int amount)
{
this.firePower += amount;
if (this.firePower > MAX_FIRE_POWER) {
@@ -7,7 +7,8 @@ package ca.bcit.comp2522.lab02;
* @author Braeden Sowinski
* @version 1.0.0
*/
public class HealingException extends RuntimeException {
public class HealingException extends RuntimeException
{
public HealingException(final String message) {
super(message);
}
@@ -7,7 +7,8 @@ package ca.bcit.comp2522.lab02;
* @author Braeden Sowinski
* @version 1.0.0
*/
public class LowFirePowerException extends Exception {
public class LowFirePowerException extends Exception
{
public LowFirePowerException(final String message) {
super(message);
}
@@ -7,7 +7,8 @@ package ca.bcit.comp2522.lab02;
* @author Braeden Sowinski
* @version 1.0.0
*/
public class LowRageException extends Exception {
public class LowRageException extends Exception
{
public LowRageException(final String message) {
super(message);
}
-1
View File
@@ -103,5 +103,4 @@ public class Orc extends Creature {
}
}
}
@@ -0,0 +1,25 @@
package ca.bcit.comp2522.project;
import java.util.Arrays;
/**
* Country class
*
* @author Braeden Sowinski
* @version 1.0.0
*/
public class Country {
final String name;
final String capitalCityName;
final String[] facts;
Country(
final String name,
final String capitalCityName,
final String[] facts
) {
this.name = name;
this.capitalCityName = capitalCityName;
this.facts = facts;
}
}
@@ -0,0 +1,54 @@
package ca.bcit.comp2522.project;
import java.util.Scanner;
/**
* Main program entry to access a games menu
*
* @author Braeden Sowinski
* @version 1.0.0
*/
public class Main {
public static void main(final String[] args) {
final Scanner scanner;
scanner = new Scanner(System.in);
boolean run = true;
do {
final String input;
System.out.println("Select a game: ");
System.out.println("Word Game (W)");
System.out.println("Number Game (N)");
System.out.println("My Game (M)");
System.out.println("Quit (Q)");
System.out.print("> ");
input = scanner.nextLine().toUpperCase();
switch (input) {
case "W":
System.out.println("Word game...");
break;
case "N":
System.out.println("Number game...");
break;
case "M":
System.out.println("My game...");
break;
case "Q":
System.out.println("Quitting...");
run = false;
break;
default:
System.out.println("Invalid input: " + input);
break;
}
} while (run);
scanner.close();
}
}