Added throws IllegalArgumentException to all required methods and made necessary variables final and static
This commit is contained in:
1 parent
0385837c0d
commit
02bc37b44f
5 files changed
+14
-8
No files matched your search
@@ -10,8 +10,8 @@ package ca.bcit.comp2522.lab03;
|
|||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
*/
|
*/
|
||||||
public abstract class IDevice {
|
public abstract class IDevice {
|
||||||
private final int MIN_PURPOSE_CHARACTER = 1;
|
private final static int MIN_PURPOSE_CHARACTER = 1;
|
||||||
private final int MAX_PURPOSE_CHARACTER = 255;
|
private final static int MAX_PURPOSE_CHARACTER = 255;
|
||||||
|
|
||||||
private final String purpose;
|
private final String purpose;
|
||||||
|
|
||||||
@@ -20,7 +20,8 @@ public abstract class IDevice {
|
|||||||
*
|
*
|
||||||
* @param purpose of IDevice
|
* @param purpose of IDevice
|
||||||
*/
|
*/
|
||||||
public IDevice(final String purpose) {
|
public IDevice(final String purpose)
|
||||||
|
{
|
||||||
|
|
||||||
stringValidator(purpose,
|
stringValidator(purpose,
|
||||||
MIN_PURPOSE_CHARACTER,
|
MIN_PURPOSE_CHARACTER,
|
||||||
@@ -64,6 +65,7 @@ public abstract class IDevice {
|
|||||||
public void stringValidator(final String toBeValidated,
|
public void stringValidator(final String toBeValidated,
|
||||||
final int minCharacterCount,
|
final int minCharacterCount,
|
||||||
final int maxCharacterCount)
|
final int maxCharacterCount)
|
||||||
|
throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
|
|
||||||
if (toBeValidated == null) {
|
if (toBeValidated == null) {
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ package ca.bcit.comp2522.lab03;
|
|||||||
*/
|
*/
|
||||||
public class IPad extends IDevice {
|
public class IPad extends IDevice {
|
||||||
|
|
||||||
private final int MAX_OSVERSION_CHARACTERS = 10;
|
private final static int MAX_OSVERSION_CHARACTERS = 10;
|
||||||
private final int MIN_OSVERSION_CHARACTERS = 1;
|
private final static int MIN_OSVERSION_CHARACTERS = 1;
|
||||||
|
|
||||||
private final boolean hasCase;
|
private final boolean hasCase;
|
||||||
private final String OSVersion;
|
private final String OSVersion;
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ public class IPhone extends IDevice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void minutesValidator(final double mins)
|
public void minutesValidator(final double mins)
|
||||||
|
throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
if(mins < NO_MINUTES_REMAINING)
|
if(mins < NO_MINUTES_REMAINING)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ package ca.bcit.comp2522.lab03;
|
|||||||
public class IPhone16 extends IPhone {
|
public class IPhone16 extends IPhone {
|
||||||
private static final int BASE_VARIANT_MEMORY = 128;
|
private static final int BASE_VARIANT_MEMORY = 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;
|
||||||
@@ -123,9 +124,10 @@ public class IPhone16 extends IPhone {
|
|||||||
* since it needs to be a multiple of 128.
|
* since it needs to be a multiple of 128.
|
||||||
* @param memoryGB passes the value of the memory to the method.
|
* @param memoryGB passes the value of the memory to the method.
|
||||||
* */
|
* */
|
||||||
public void memoryGBValidator(int memoryGB)
|
public void memoryGBValidator(final int memoryGB)
|
||||||
|
throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
if (memoryGB % BASE_VARIANT_MEMORY != 0)
|
if (memoryGB % BASE_VARIANT_MEMORY != IS_A_MULTIPLE_OF_BASE_VARIANT)
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException("Invalid Memory value (GB)");
|
throw new IllegalArgumentException("Invalid Memory value (GB)");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,7 +129,8 @@ public class IPod extends IDevice {
|
|||||||
* passed are not negative.
|
* passed are not negative.
|
||||||
* @param songNumber passes the value of the number of songs.
|
* @param songNumber passes the value of the number of songs.
|
||||||
* */
|
* */
|
||||||
public void numberOfSongsValidator(int songNumber)
|
public void numberOfSongsValidator(final int songNumber)
|
||||||
|
throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
if(songNumber < NO_SONGS)
|
if(songNumber < NO_SONGS)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user