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

No files matched your search

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