Created memoryGB validator

This commit is contained in:
Trishaan committed 2025-09-29 01:45:21 -07:00
1 parent a35e706c88
commit e24adee9cc
1 file changed
+11 -3
+11 -3
View File
@@ -10,7 +10,7 @@ package ca.bcit.comp2522.lab03;
* @version 1.0.0 * @version 1.0.0
*/ */
public class IPhone16 extends IPhone { public class IPhone16 extends IPhone {
private static final int BASE_VARIANT_MEMORY = 16;
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;
@@ -31,9 +31,9 @@ public class IPhone16 extends IPhone {
) { ) {
super(remainingPhonePlanMinutes, carrier); super(remainingPhonePlanMinutes, carrier);
// TODO: validate memoryGB input?
this.highResolutionCamera = highResolutionCamera; this.highResolutionCamera = highResolutionCamera;
memoryGBValidator(memoryGB);
this.memoryGB = memoryGB; this.memoryGB = memoryGB;
} }
@@ -117,4 +117,12 @@ public class IPhone16 extends IPhone {
return hash; return hash;
} }
public void memoryGBValidator(int memoryGB)
{
if (memoryGB % BASE_VARIANT_MEMORY != 0)
{
throw new IllegalArgumentException("Invalid Memory value (GB)");
}
}
} }