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

@@ -7,6 +7,7 @@ package ca.bcit.comp2522.lab03;
* @author Braeden Sowinski
* @author Nicolas Agostini
* @author Trishaan Shetty
* * @author Calvin Arifianto
* @version 1.0.0
*/
public abstract class IDevice
@@ -78,12 +79,15 @@ public abstract class IDevice
if (toBeValidated == null) {
throw new IllegalArgumentException("Value cannot be null");
}
if (toBeValidated.isEmpty()) {
throw new IllegalArgumentException("Value cannot be empty");
}
if (toBeValidated.isBlank()) {
throw new IllegalArgumentException("Value cannot be blank");
}
if (toBeValidated.length() < minCharacterCount ||
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 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_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
{
private static final int BASE_VARIANT_MEMORY_GB = 128;
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 int memoryGB;
@@ -36,7 +34,6 @@ public class IPhone16 extends IPhone
this.highResolutionCamera = highResolutionCamera;
memoryGBValidator(memoryGB);
this.memoryGB = memoryGB;
}
@@ -123,18 +120,4 @@ public class IPhone16 extends IPhone
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
{
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_CODE = 97;
@@ -135,11 +135,10 @@ public class IPod extends IDevice
* @param songNumber passes the value of the number of songs.
* */
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);
}
}
}