fix lab03

This commit is contained in:
SowinskiBraeden committed 2025-09-29 14:17:52 -07:00
1 parent af69fe5caa
commit a2d3c94198
5 files changed
+18 -31

No files matched your search

+1 -4
View File
@@ -5,12 +5,9 @@
</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/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/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/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/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/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/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/lab03/IPod.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab03/IPod.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" />
@@ -116,7 +113,7 @@
<workItem from="1758425336799" duration="21000" /> <workItem from="1758425336799" duration="21000" />
<workItem from="1758473282464" duration="4563000" /> <workItem from="1758473282464" duration="4563000" />
<workItem from="1758570032207" duration="7053000" /> <workItem from="1758570032207" duration="7053000" />
<workItem from="1759179533296" duration="509000" /> <workItem from="1759179533296" duration="997000" />
</task> </task>
<servers /> <servers />
</component> </component>
@@ -7,6 +7,7 @@ package ca.bcit.comp2522.lab03;
* @author Braeden Sowinski * @author Braeden Sowinski
* @author Nicolas Agostini * @author Nicolas Agostini
* @author Trishaan Shetty * @author Trishaan Shetty
* * @author Calvin Arifianto
* @version 1.0.0 * @version 1.0.0
*/ */
public abstract class IDevice public abstract class IDevice
@@ -78,12 +79,15 @@ public abstract class IDevice
if (toBeValidated == null) { if (toBeValidated == null) {
throw new IllegalArgumentException("Value cannot be null"); throw new IllegalArgumentException("Value cannot be null");
} }
if (toBeValidated.isEmpty()) { if (toBeValidated.isEmpty()) {
throw new IllegalArgumentException("Value cannot be empty"); throw new IllegalArgumentException("Value cannot be empty");
} }
if (toBeValidated.isBlank()) { if (toBeValidated.isBlank()) {
throw new IllegalArgumentException("Value cannot be blank"); throw new IllegalArgumentException("Value cannot be blank");
} }
if (toBeValidated.length() < minCharacterCount || if (toBeValidated.length() < minCharacterCount ||
toBeValidated.length() > maxCharacterCount toBeValidated.length() > maxCharacterCount
) )
+10 -6
View File
@@ -14,7 +14,7 @@ public class IPhone extends IDevice
private static final int MIN_CAREER_CHARACTERS = 3; private static final int MIN_CAREER_CHARACTERS = 3;
private static final int MAX_CAREER_CHARACTERS = 15; private static final int MAX_CAREER_CHARACTERS = 15;
private static final double NO_MINUTES_REMAINING = 0.0; private static final double MIN_MINUTES_REMAINING = 0.0;
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;
@@ -137,13 +137,17 @@ public class IPhone extends IDevice
} }
public void minutesValidator(final double mins) /**
throws IllegalArgumentException * minutesValidator ensures that a given number of minutes
* is not less than the minimum.
* @param mins to verify
*/
public static void minutesValidator(final double mins)
{ {
if(mins < NO_MINUTES_REMAINING) if(mins < MIN_MINUTES_REMAINING)
{ {
throw new IllegalArgumentException("Minutes cannot be negative"); throw new IllegalArgumentException("Minutes cannot be less than " +
MIN_MINUTES_REMAINING + " minutes");
} }
} }
} }
@@ -12,9 +12,7 @@ package ca.bcit.comp2522.lab03;
public class IPhone16 extends IPhone public class IPhone16 extends IPhone
{ {
private static final int BASE_VARIANT_MEMORY_GB = 128;
private static final int IPHONE_HASH_WITH_HIGH_RES = 103; private static final int IPHONE_HASH_WITH_HIGH_RES = 103;
private static final int IS_A_MULTIPLE_OF_BASE_VARIANT = 0;
final boolean highResolutionCamera; final boolean highResolutionCamera;
final int memoryGB; final int memoryGB;
@@ -36,7 +34,6 @@ public class IPhone16 extends IPhone
this.highResolutionCamera = highResolutionCamera; this.highResolutionCamera = highResolutionCamera;
memoryGBValidator(memoryGB);
this.memoryGB = memoryGB; this.memoryGB = memoryGB;
} }
@@ -123,18 +120,4 @@ public class IPhone16 extends IPhone
return hash; return hash;
} }
/**
* memoryGBValidator makes sure the right memory storage is assigned
* since it needs to be a multiple of 128.
* @param memoryGB passes the value of the memory to the method.
* */
public void memoryGBValidator(final int memoryGB)
throws IllegalArgumentException
{
if (memoryGB % BASE_VARIANT_MEMORY_GB != IS_A_MULTIPLE_OF_BASE_VARIANT)
{
throw new IllegalArgumentException("Invalid Memory value (GB)");
}
}
} }
+3 -4
View File
@@ -12,7 +12,7 @@ package ca.bcit.comp2522.lab03;
public class IPod extends IDevice public class IPod extends IDevice
{ {
private static final int NO_SONGS = 0; private static final int MIN_SONGS = 0;
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;
@@ -135,11 +135,10 @@ public class IPod extends IDevice
* @param songNumber passes the value of the number of songs. * @param songNumber passes the value of the number of songs.
* */ * */
public void numberOfSongsValidator(final int songNumber) public void numberOfSongsValidator(final int songNumber)
throws IllegalArgumentException
{ {
if(songNumber < NO_SONGS) if(songNumber < MIN_SONGS)
{ {
throw new IllegalArgumentException("Number of songs cannot be less than 0"); throw new IllegalArgumentException("Number of songs cannot be less than " + MIN_SONGS);
} }
} }
} }