add TODOs to lab03 + cleaner formatting

This commit is contained in:
SowinskiBraeden committed 2025-09-22 14:07:36 -07:00
1 parent 95139d77e5
commit 3e24aa6522
7 files changed
+75 -13

No files matched your search

+7 -11
View File
@@ -5,16 +5,12 @@
</component> </component>
<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$/src/code/ca/bcit/comp2522/lab03/IDevice.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab03/IDevice.java" 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/lab03/IPad.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab03/IPad.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/lab03/IPhone.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab03/IPhone.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/lab03/IPhone16.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab03/IPhone16.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/lab03/IPod.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab03/IPod.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/lab03/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab03/Main.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" />
@@ -119,7 +115,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="2682000" /> <workItem from="1758570032207" duration="3338000" />
</task> </task>
<servers /> <servers />
</component> </component>
@@ -5,9 +5,12 @@ package ca.bcit.comp2522.lab03;
* devices and common functionality. * devices and common functionality.
* *
* @author Braeden Sowinski * @author Braeden Sowinski
* @author Nicolas Agostini
* @author Trishaan Shetty
* @version 1.0.0 * @version 1.0.0
*/ */
public abstract class IDevice { public abstract class IDevice {
private final String purpose; private final String purpose;
/** /**
@@ -15,6 +18,8 @@ public abstract class IDevice {
* @param purpose of IDevice * @param purpose of IDevice
*/ */
public IDevice(final String purpose) { public IDevice(final String purpose) {
// TODO: validate String inputs
this.purpose = purpose; this.purpose = purpose;
} }
+21 -1
View File
@@ -5,9 +5,12 @@ package ca.bcit.comp2522.lab03;
* such as operating system version, and if it has a case. * such as operating system version, and if it has a case.
* *
* @author Braeden Sowinski * @author Braeden Sowinski
* @author Nicolas Agostini
* @author Trishaan Shetty
* @version 1.0.0 * @version 1.0.0
*/ */
public class IPad extends IDevice { public class IPad extends IDevice {
private final boolean hasCase; private final boolean hasCase;
private final String OSVersion; private final String OSVersion;
@@ -22,6 +25,7 @@ public class IPad extends IDevice {
) { ) {
super("learning"); super("learning");
// TODO: validate String inputs
this.hasCase = hasCase; this.hasCase = hasCase;
this.OSVersion = OSVersion; this.OSVersion = OSVersion;
} }
@@ -39,6 +43,7 @@ public class IPad extends IDevice {
* and which operating system version it is running * and which operating system version it is running
*/ */
public void printDetails() { public void printDetails() {
final StringBuilder details; final StringBuilder details;
details = new StringBuilder(); details = new StringBuilder();
@@ -49,6 +54,7 @@ public class IPad extends IDevice {
details.append(this.OSVersion); details.append(this.OSVersion);
System.out.println(details.toString()); System.out.println(details.toString());
} }
/** /**
@@ -57,7 +63,19 @@ public class IPad extends IDevice {
*/ */
@Override @Override
public String toString() { public String toString() {
return super.toString() + " " + this.hasCase + " " + this.OSVersion;
final StringBuilder details;
details = new StringBuilder();
details.append(super.toString());
details.append(" ");
details.append(this.hasCase);
details.append(" ");
details.append(this.OSVersion);
return details.toString();
} }
/** /**
@@ -68,6 +86,7 @@ public class IPad extends IDevice {
*/ */
@Override @Override
public boolean equals(final Object o) { public boolean equals(final Object o) {
// Ensure object exists // Ensure object exists
if (o == null) { if (o == null) {
return false; return false;
@@ -83,6 +102,7 @@ public class IPad extends IDevice {
otherIPad = (IPad) o; otherIPad = (IPad) o;
return otherIPad.getOSVersion().equals(this.OSVersion); return otherIPad.getOSVersion().equals(this.OSVersion);
} }
/** /**
+14 -1
View File
@@ -5,9 +5,12 @@ package ca.bcit.comp2522.lab03;
* how many minutes remain on the phone plan. * how many minutes remain on the phone plan.
* *
* @author Braeden Sowinski * @author Braeden Sowinski
* @author Nicolas Agostini
* @author Trishaan Shetty
* @version 1.0.0 * @version 1.0.0
*/ */
public class IPhone extends IDevice { public class IPhone extends IDevice {
private static final int IPHONE_HASH = 11; private static final int IPHONE_HASH = 11;
private static final int IPHONE_HASH_CODE = 101; private static final int IPHONE_HASH_CODE = 101;
@@ -25,6 +28,7 @@ public class IPhone extends IDevice {
) { ) {
super("talking"); super("talking");
// TODO: validate String inputs, possibly other inputs too
this.remainingPhonePlanMinutes = remainingPhonePlanMinutes; this.remainingPhonePlanMinutes = remainingPhonePlanMinutes;
this.carrier = carrier; this.carrier = carrier;
} }
@@ -42,6 +46,7 @@ public class IPhone extends IDevice {
* phone plan minutes * phone plan minutes
*/ */
public void printDetails() { public void printDetails() {
final StringBuilder details; final StringBuilder details;
details = new StringBuilder(); details = new StringBuilder();
@@ -52,6 +57,7 @@ public class IPhone extends IDevice {
details.append(")"); details.append(")");
System.out.println(details.toString()); System.out.println(details.toString());
} }
/** /**
@@ -60,10 +66,11 @@ public class IPhone extends IDevice {
*/ */
@Override @Override
public String toString() { public String toString() {
// TODO: convert to StringBuilder, refer to IPad
return super.toString() + " " + this.remainingPhonePlanMinutes + " " + this.carrier; return super.toString() + " " + this.remainingPhonePlanMinutes + " " + this.carrier;
} }
/** /**
* equals check if a given IPhone has the same remaining * equals check if a given IPhone has the same remaining
* phone plan minutes as this IPhone. * phone plan minutes as this IPhone.
@@ -72,6 +79,7 @@ public class IPhone extends IDevice {
*/ */
@Override @Override
public boolean equals(final Object o) { public boolean equals(final Object o) {
// Ensure object exists // Ensure object exists
if (o == null) { if (o == null) {
return false; return false;
@@ -87,6 +95,7 @@ public class IPhone extends IDevice {
otherIPhone = (IPhone) o; otherIPhone = (IPhone) o;
return otherIPhone.getRemainingPhonePlanMinutes() == this.remainingPhonePlanMinutes; return otherIPhone.getRemainingPhonePlanMinutes() == this.remainingPhonePlanMinutes;
} }
/** /**
@@ -95,8 +104,12 @@ public class IPhone extends IDevice {
*/ */
@Override @Override
public int hashCode() { public int hashCode() {
int hash; int hash;
hash = IPHONE_HASH_CODE * IPHONE_HASH * (int) this.remainingPhonePlanMinutes; hash = IPHONE_HASH_CODE * IPHONE_HASH * (int) this.remainingPhonePlanMinutes;
return hash; return hash;
} }
} }
@@ -5,9 +5,12 @@ package ca.bcit.comp2522.lab03;
* features. * features.
* *
* @author Braeden Sowinski * @author Braeden Sowinski
* @author Nicolas Agostini
* @author Trishaan Shetty
* @version 1.0.0 * @version 1.0.0
*/ */
public class IPhone16 extends IPhone { public class IPhone16 extends IPhone {
private static final int IPHONE_HASH_WITH_HIGH_RES = 103; private static final int IPHONE_HASH_WITH_HIGH_RES = 103;
final boolean highResolutionCamera; final boolean highResolutionCamera;
@@ -28,6 +31,8 @@ public class IPhone16 extends IPhone {
) { ) {
super(remainingPhonePlanMinutes, carrier); super(remainingPhonePlanMinutes, carrier);
// TODO: validate memoryGB input?
this.highResolutionCamera = highResolutionCamera; this.highResolutionCamera = highResolutionCamera;
this.memoryGB = memoryGB; this.memoryGB = memoryGB;
} }
@@ -46,6 +51,7 @@ public class IPhone16 extends IPhone {
*/ */
@Override @Override
public String toString() { public String toString() {
final StringBuilder builder; final StringBuilder builder;
builder = new StringBuilder(); builder = new StringBuilder();
@@ -56,6 +62,7 @@ public class IPhone16 extends IPhone {
builder.append(this.memoryGB); builder.append(this.memoryGB);
return builder.toString(); return builder.toString();
} }
/** /**
@@ -67,6 +74,7 @@ public class IPhone16 extends IPhone {
*/ */
@Override @Override
public boolean equals(final Object o) { public boolean equals(final Object o) {
// Ensure object exists // Ensure object exists
if (o == null) { if (o == null) {
return false; return false;
@@ -88,6 +96,7 @@ public class IPhone16 extends IPhone {
matchingCameraResolution = this.highResolutionCamera && otherIPhone.getHighResolutionCamera(); matchingCameraResolution = this.highResolutionCamera && otherIPhone.getHighResolutionCamera();
return matchingMinutes && matchingCameraResolution; return matchingMinutes && matchingCameraResolution;
} }
/** /**
@@ -96,6 +105,7 @@ public class IPhone16 extends IPhone {
*/ */
@Override @Override
public int hashCode() { public int hashCode() {
int hash; int hash;
hash = super.hashCode(); hash = super.hashCode();
@@ -105,5 +115,6 @@ public class IPhone16 extends IPhone {
} }
return hash; return hash;
} }
} }
+15
View File
@@ -5,9 +5,12 @@ package ca.bcit.comp2522.lab03;
* volume in decibels. * volume in decibels.
* *
* @author Braeden Sowinski * @author Braeden Sowinski
* @author Nicolas Agostini
* @author Trishaan Shetty
* @version 1.0.0 * @version 1.0.0
*/ */
public class IPod extends IDevice { public class IPod extends IDevice {
private static final int IPOD_HASH = 7; private static final int IPOD_HASH = 7;
private static final int IPOD_HASH_CODE = 97; private static final int IPOD_HASH_CODE = 97;
@@ -25,6 +28,8 @@ public class IPod extends IDevice {
) { ) {
super("music"); super("music");
// TODO: validate numberOfSongs input
this.numberOfSongs = numberOfSongs; this.numberOfSongs = numberOfSongs;
this.maxVolumeDecibels = maxVolumeDecibels; this.maxVolumeDecibels = maxVolumeDecibels;
} }
@@ -34,6 +39,7 @@ public class IPod extends IDevice {
* and max volume in decibels. * and max volume in decibels.
*/ */
public void printDetails() { public void printDetails() {
final StringBuilder details; final StringBuilder details;
details = new StringBuilder(); details = new StringBuilder();
@@ -44,6 +50,7 @@ public class IPod extends IDevice {
details.append(" dB."); details.append(" dB.");
System.out.println(details.toString()); System.out.println(details.toString());
} }
/** /**
@@ -60,6 +67,8 @@ public class IPod extends IDevice {
*/ */
@Override @Override
public String toString() { public String toString() {
// TODO: change this to StringBuilder, refer to IPad
return super.toString() + " " + this.numberOfSongs + " " + this.maxVolumeDecibels; return super.toString() + " " + this.numberOfSongs + " " + this.maxVolumeDecibels;
} }
@@ -71,6 +80,7 @@ public class IPod extends IDevice {
*/ */
@Override @Override
public boolean equals(final Object o) { public boolean equals(final Object o) {
// Ensure object exists // Ensure object exists
if (o == null) { if (o == null) {
return false; return false;
@@ -86,6 +96,7 @@ public class IPod extends IDevice {
otherIPod = (IPod) o; otherIPod = (IPod) o;
return otherIPod.getNumberOfSongs() == this.numberOfSongs; return otherIPod.getNumberOfSongs() == this.numberOfSongs;
} }
/** /**
@@ -94,8 +105,12 @@ public class IPod extends IDevice {
*/ */
@Override @Override
public int hashCode() { public int hashCode() {
int hash; int hash;
hash = IPOD_HASH_CODE * IPOD_HASH + this.numberOfSongs; hash = IPOD_HASH_CODE * IPOD_HASH + this.numberOfSongs;
return hash; return hash;
} }
} }
@@ -4,6 +4,8 @@ package ca.bcit.comp2522.lab03;
* Main class to test IDevice classes, and abstract concepts. * Main class to test IDevice classes, and abstract concepts.
* *
* @author Braeden Sowinski * @author Braeden Sowinski
* @author Nicolas Agostini
* @author Trishaan Shetty
* @version 1.0.0 * @version 1.0.0
*/ */
public class Main { public class Main {