final tidy of lab02
This commit is contained in:
10 files changed
+76
-10
No files matched your search
Generated
+7
-1
@@ -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,10 +4,13 @@ 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;
|
||||||
@@ -68,10 +71,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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,12 @@ 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 {
|
||||||
|
|
||||||
private static final int MAX_FIRE_POWER = 100;
|
private static final int MAX_FIRE_POWER = 100;
|
||||||
private static final int MIN_FIRE_POWER = 0;
|
private static final int MIN_FIRE_POWER = 0;
|
||||||
private static final int FIRE_POWER_USAGE = 10;
|
private static final int FIRE_POWER_USAGE = 10;
|
||||||
@@ -25,7 +28,6 @@ public class Dragon extends Creature {
|
|||||||
private static void validateFirePower(final int firePower)
|
private static void validateFirePower(final int firePower)
|
||||||
throws IllegalArgumentException
|
throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
|
|
||||||
if (firePower < MIN_FIRE_POWER || firePower > MAX_FIRE_POWER) {
|
if (firePower < MIN_FIRE_POWER || firePower > MAX_FIRE_POWER) {
|
||||||
throw new IllegalArgumentException("Fire power is outside of valid range.");
|
throw new IllegalArgumentException("Fire power is outside of valid range.");
|
||||||
}
|
}
|
||||||
@@ -60,7 +62,8 @@ public class Dragon extends Creature {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDetails() {
|
public String getDetails() {
|
||||||
StringBuilder builder;
|
|
||||||
|
final StringBuilder builder;
|
||||||
|
|
||||||
builder = new StringBuilder();
|
builder = new StringBuilder();
|
||||||
|
|
||||||
@@ -84,7 +87,8 @@ public class Dragon extends Creature {
|
|||||||
* @throws RuntimeException if the dragon is not alive to accomplish the action
|
* @throws RuntimeException if the dragon is not alive to accomplish the action
|
||||||
*/
|
*/
|
||||||
public void breatheFire(final Creature target)
|
public void breatheFire(final Creature target)
|
||||||
throws LowFirePowerException, RuntimeException {
|
throws LowFirePowerException, RuntimeException
|
||||||
|
{
|
||||||
|
|
||||||
if (!this.isAlive()) {
|
if (!this.isAlive()) {
|
||||||
throw new RuntimeException("The dragon is not alive.");
|
throw new RuntimeException("The dragon is not alive.");
|
||||||
@@ -107,10 +111,12 @@ public class Dragon extends Creature {
|
|||||||
* @param amount to increase firePower
|
* @param amount to increase firePower
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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,9 +5,16 @@ 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 {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HealingException constructor
|
||||||
|
* @param message HealingException error message
|
||||||
|
*/
|
||||||
public HealingException(final String message) {
|
public HealingException(final String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,16 @@ 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 {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LowFirePowerException constructor
|
||||||
|
* @param message LowFirePowerException error message
|
||||||
|
*/
|
||||||
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,9 +5,16 @@ 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
|
||||||
*/
|
*/
|
||||||
public class LowRageException extends Exception {
|
public class LowRageException extends Exception {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LowRageException constructor
|
||||||
|
* @param message LowRageException error message
|
||||||
|
*/
|
||||||
public LowRageException(final String message) {
|
public LowRageException(final String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user