This commit is contained in:
nicoagostini committed 2025-09-22 14:05:34 -07:00
commit 27350029ab
10 files changed
+68 -8

No files matched your search

+7 -1
View File
@@ -6,9 +6,15 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="4481728b-524b-48ee-9d70-e414a15f05bd" name="Changes" comment=""> <list default="true" id="4481728b-524b-48ee-9d70-e414a15f05bd" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab02/Creature.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab02/Creature.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab02/DamageException.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab02/DamageException.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab02/DamageException.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab02/DamageException.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab02/Dragon.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab02/Dragon.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab02/Dragon.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab02/Dragon.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab02/Elf.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab02/Elf.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab02/HealingException.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab02/HealingException.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab02/HealingException.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab02/HealingException.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab02/LowFirePowerException.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab02/LowFirePowerException.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab02/LowManaException.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab02/LowManaException.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab02/LowRageException.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab02/LowRageException.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab02/Orc.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab02/Orc.java" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -113,7 +119,7 @@
<workItem from="1758413771974" duration="332000" /> <workItem from="1758413771974" duration="332000" />
<workItem from="1758425336799" duration="21000" /> <workItem from="1758425336799" duration="21000" />
<workItem from="1758473282464" duration="4563000" /> <workItem from="1758473282464" duration="4563000" />
<workItem from="1758570032207" duration="1691000" /> <workItem from="1758570032207" duration="2682000" />
</task> </task>
<servers /> <servers />
</component> </component>
@@ -4,11 +4,14 @@ package ca.bcit.comp2522.lab02;
* Creature contains simple information regarding * Creature contains simple information regarding
* a creature such as its health, name and date of birth. * a creature such as its health, name and date of birth.
* *
* @author Braeden Sowinski, Nicolas Agostini, Trishaan Shetty * @author Braeden Sowinski
* @author Nicolas Agostini
* @author Trishaan Shetty
* @version 1.0.0 * @version 1.0.0
*/ */
public class Creature public class Creature
{ {
private static final int MIN_HEALTH = 1; private static final int MIN_HEALTH = 1;
private static final int MAX_HEALTH = 100; private static final int MAX_HEALTH = 100;
private static final int NO_HEALTH = 0; private static final int NO_HEALTH = 0;
@@ -69,10 +72,11 @@ public class Creature
* @param dateOfBirth of creature * @param dateOfBirth of creature
* @param health of creature to start * @param health of creature to start
*/ */
public Creature(final String name, public Creature(
final String name,
final Date dateOfBirth, final Date dateOfBirth,
final int health) final int health
{ ) {
validateName(name); validateName(name);
validateDateOfBirth(dateOfBirth); validateDateOfBirth(dateOfBirth);
@@ -5,9 +5,16 @@ package ca.bcit.comp2522.lab02;
* for when a given damage value is invalid. * for when a given damage value is invalid.
* *
* @author Braeden Sowinski * @author Braeden Sowinski
* @author Nicolas Agostini
* @author Trishaan Shetty
* @version 1.0.0 * @version 1.0.0
*/ */
public class DamageException extends RuntimeException { public class DamageException extends RuntimeException {
/**
* DamageException constructor
* @param message of DamageException error
*/
public DamageException(final String message) { public DamageException(final String message) {
super(message); super(message);
} }
+6 -1
View File
@@ -5,6 +5,8 @@ package ca.bcit.comp2522.lab02;
* holds a firePower value. * holds a firePower value.
* *
* @author Braeden Sowinski * @author Braeden Sowinski
* @author Nicolas Agostini
* @author Trishaan Shetty
* @version 1.0.0 * @version 1.0.0
*/ */
public class Dragon extends Creature public class Dragon extends Creature
@@ -63,8 +65,10 @@ public class Dragon extends Creature
public String getDetails() public String getDetails()
{ {
final StringBuilder builder; final StringBuilder builder;
builder = new StringBuilder(); builder = new StringBuilder();
builder.append("Is alive: " + this.isAlive()); builder.append("Is alive: " + this.isAlive());
builder.append(" Name: " + this.getName()); builder.append(" Name: " + this.getName());
builder.append(" Date of birth: " + (this.getDateOfBirth()).getYyyyMmDd()); builder.append(" Date of birth: " + (this.getDateOfBirth()).getYyyyMmDd());
@@ -73,7 +77,6 @@ public class Dragon extends Creature
builder.append(" FirePower: " + this.firePower); builder.append(" FirePower: " + this.firePower);
return builder.toString(); return builder.toString();
} }
@@ -112,10 +115,12 @@ public class Dragon extends Creature
*/ */
protected void restoreFirePower(final int amount) protected void restoreFirePower(final int amount)
{ {
this.firePower += amount; this.firePower += amount;
if (this.firePower > MAX_FIRE_POWER) { if (this.firePower > MAX_FIRE_POWER) {
this.firePower = MAX_FIRE_POWER; this.firePower = MAX_FIRE_POWER;
} }
} }
} }
+9 -1
View File
@@ -5,9 +5,12 @@ package ca.bcit.comp2522.lab02;
* holds a mana value * holds a mana value
* *
* @author Braeden Sowinski * @author Braeden Sowinski
* @author Nicolas Agostini
* @author Trishaan Shetty
* @version 1.0.0 * @version 1.0.0
*/ */
public class Elf extends Creature { public class Elf extends Creature {
private static final int MIN_MANA_VALUE = 0; private static final int MIN_MANA_VALUE = 0;
private static final int MAX_MANA_VALUE = 50; private static final int MAX_MANA_VALUE = 50;
private static final int MANA_DAMAGE = 10; private static final int MANA_DAMAGE = 10;
@@ -58,8 +61,11 @@ public class Elf extends Creature {
*/ */
@Override @Override
public String getDetails() { public String getDetails() {
StringBuilder builder;
final StringBuilder builder;
builder = new StringBuilder(); builder = new StringBuilder();
builder.append("Is alive: " + this.isAlive()); builder.append("Is alive: " + this.isAlive());
builder.append(" Name: " + this.getName()); builder.append(" Name: " + this.getName());
builder.append(" Date of birth: " + (this.getDateOfBirth()).getYyyyMmDd()); builder.append(" Date of birth: " + (this.getDateOfBirth()).getYyyyMmDd());
@@ -102,10 +108,12 @@ public class Elf extends Creature {
* @param amount to increase mana * @param amount to increase mana
*/ */
protected void restoreMana(final int amount) { protected void restoreMana(final int amount) {
this.mana += amount; this.mana += amount;
if (this.mana > MAX_MANA_VALUE) { if (this.mana > MAX_MANA_VALUE) {
this.mana = MAX_MANA_VALUE; this.mana = MAX_MANA_VALUE;
} }
} }
} }
@@ -5,6 +5,8 @@ package ca.bcit.comp2522.lab02;
* for when a given healing value is invalid. * for when a given healing value is invalid.
* *
* @author Braeden Sowinski * @author Braeden Sowinski
* @author Nicolas Agostini
* @author Trishaan Shetty
* @version 1.0.0 * @version 1.0.0
*/ */
public class HealingException extends RuntimeException public class HealingException extends RuntimeException
@@ -5,10 +5,13 @@ package ca.bcit.comp2522.lab02;
* when firePower is too low to deal damage. * when firePower is too low to deal damage.
* *
* @author Braeden Sowinski * @author Braeden Sowinski
* @author Nicolas Agostini
* @author Trishaan Shetty
* @version 1.0.0 * @version 1.0.0
*/ */
public class LowFirePowerException extends Exception public class LowFirePowerException extends Exception
{ {
public LowFirePowerException(final String message) { public LowFirePowerException(final String message) {
super(message); super(message);
} }
@@ -5,9 +5,16 @@ package ca.bcit.comp2522.lab02;
* when mana is too low to deal damage. * when mana is too low to deal damage.
* *
* @author Braeden Sowinski * @author Braeden Sowinski
* @author Nicolas Agostini
* @author Trishaan Shetty
* @version 1.0.0 * @version 1.0.0
*/ */
public class LowManaException extends Exception { public class LowManaException extends Exception {
/**
* LowManaException constructor
* @param message LowManaException error message
*/
public LowManaException(final String message) { public LowManaException(final String message) {
super(message); super(message);
} }
@@ -5,10 +5,21 @@ package ca.bcit.comp2522.lab02;
* when rage is too low to deal damage. * when rage is too low to deal damage.
* *
* @author Braeden Sowinski * @author Braeden Sowinski
* @author Nicolas Agostini
* @author Trishaan Shetty
* @version 1.0.0 * @version 1.0.0
*/ */
<<<<<<< HEAD
public class LowRageException extends Exception public class LowRageException extends Exception
{ {
=======
public class LowRageException extends Exception {
/**
* LowRageException constructor
* @param message LowRageException error message
*/
>>>>>>> 95139d77e5ef179a1fdf39684f766170502c6138
public LowRageException(final String message) { public LowRageException(final String message) {
super(message); super(message);
} }
+8 -1
View File
@@ -5,9 +5,12 @@ package ca.bcit.comp2522.lab02;
* holds a rage value. Orcs need anger management. * holds a rage value. Orcs need anger management.
* *
* @author Braeden Sowinski * @author Braeden Sowinski
* @author Nicolas Agostini
* @author Trishaan Shetty
* @version 1.0.0 * @version 1.0.0
*/ */
public class Orc extends Creature { public class Orc extends Creature {
private static final int MIN_RAGE_VALUE = 0; private static final int MIN_RAGE_VALUE = 0;
private static final int MAX_RAGE_VALUE = 30; private static final int MAX_RAGE_VALUE = 30;
private static final int RAGE_INCREMENT = 5; private static final int RAGE_INCREMENT = 5;
@@ -60,8 +63,11 @@ public class Orc extends Creature {
*/ */
@Override @Override
public String getDetails() { public String getDetails() {
StringBuilder builder;
final StringBuilder builder;
builder = new StringBuilder(); builder = new StringBuilder();
builder.append("Is alive: " + this.isAlive()); builder.append("Is alive: " + this.isAlive());
builder.append(" Name: " + this.getName()); builder.append(" Name: " + this.getName());
builder.append(" Date of birth: " + (this.getDateOfBirth()).getYyyyMmDd()); builder.append(" Date of birth: " + (this.getDateOfBirth()).getYyyyMmDd());
@@ -84,6 +90,7 @@ public class Orc extends Creature {
public void berserk(final Creature target) public void berserk(final Creature target)
throws LowRageException, RuntimeException throws LowRageException, RuntimeException
{ {
if(!this.isAlive()){ if(!this.isAlive()){
throw new RuntimeException("The orc is not alive."); throw new RuntimeException("The orc is not alive.");
} }