From af69fe5caa18586a71b6230a1b7ed292b6016bb7 Mon Sep 17 00:00:00 2001 From: SowinskiBraeden Date: Mon, 29 Sep 2025 14:07:32 -0700 Subject: [PATCH] tidy lab03 --- .idea/workspace.xml | 45 ++++++++++--------- src/code/ca/bcit/comp2522/lab03/IDevice.java | 32 ++++++++----- src/code/ca/bcit/comp2522/lab03/IPad.java | 31 ++++++++----- src/code/ca/bcit/comp2522/lab03/IPhone.java | 39 +++++++++------- src/code/ca/bcit/comp2522/lab03/IPhone16.java | 21 +++++---- src/code/ca/bcit/comp2522/lab03/IPod.java | 21 +++++---- 6 files changed, 114 insertions(+), 75 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 7a20347..730bbed 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,12 +5,12 @@ + - - { + "keyToString": { + "Application.Main.executor": "Run", + "ModuleVcsDetector.initialDetectionPerformed": "true", + "RunOnceActivity.ShowReadmeOnStart": "true", + "RunOnceActivity.git.unshallow": "true", + "git-widget-placeholder": "main", + "kotlin-language-version-configured": "true", + "last_opened_file_path": "/home/flami/Projects/comp2522", + "node.js.detected.package.eslint": "true", + "node.js.detected.package.tslint": "true", + "node.js.selected.package.eslint": "(autodetect)", + "node.js.selected.package.tslint": "(autodetect)", + "nodejs_package_manager_path": "npm", + "project.structure.last.edited": "Project", + "project.structure.proportion": "0.15", + "project.structure.side.proportion": "0.2", + "settings.editor.selected.configurable": "preferences.lookFeel", + "vue.rearranger.settings.migration": "true" } -}]]> +} @@ -115,7 +115,8 @@ - + + diff --git a/src/code/ca/bcit/comp2522/lab03/IDevice.java b/src/code/ca/bcit/comp2522/lab03/IDevice.java index f0f5c90..69dd990 100644 --- a/src/code/ca/bcit/comp2522/lab03/IDevice.java +++ b/src/code/ca/bcit/comp2522/lab03/IDevice.java @@ -9,7 +9,9 @@ package ca.bcit.comp2522.lab03; * @author Trishaan Shetty * @version 1.0.0 */ -public abstract class IDevice { +public abstract class IDevice +{ + private final static int MIN_PURPOSE_CHARACTER = 1; private final static int MAX_PURPOSE_CHARACTER = 255; @@ -23,9 +25,12 @@ public abstract class IDevice { public IDevice(final String purpose) { - stringValidator(purpose, - MIN_PURPOSE_CHARACTER, - MAX_PURPOSE_CHARACTER); + stringValidator( + purpose, + MIN_PURPOSE_CHARACTER, + MAX_PURPOSE_CHARACTER + ); + this.purpose = purpose; } @@ -62,10 +67,12 @@ public abstract class IDevice { * @param minCharacterCount passes the minimum number of characters that can be accepted * as an integer. * */ - public void stringValidator(final String toBeValidated, - final int minCharacterCount, - final int maxCharacterCount) - throws IllegalArgumentException + public void stringValidator( + final String toBeValidated, + final int minCharacterCount, + final int maxCharacterCount + ) + throws IllegalArgumentException { if (toBeValidated == null) { @@ -77,9 +84,12 @@ public abstract class IDevice { if (toBeValidated.isBlank()) { throw new IllegalArgumentException("Value cannot be blank"); } - if (toBeValidated.length() < minCharacterCount || toBeValidated.length() > maxCharacterCount) { - throw new IllegalArgumentException("Value length must be between" - + minCharacterCount + "and " + maxCharacterCount + " characters"); + if (toBeValidated.length() < minCharacterCount || + toBeValidated.length() > maxCharacterCount + ) + { + throw new IllegalArgumentException("Value length must be between" + + minCharacterCount + "and " + maxCharacterCount + " characters"); } } } diff --git a/src/code/ca/bcit/comp2522/lab03/IPad.java b/src/code/ca/bcit/comp2522/lab03/IPad.java index d91bcdf..3708a85 100644 --- a/src/code/ca/bcit/comp2522/lab03/IPad.java +++ b/src/code/ca/bcit/comp2522/lab03/IPad.java @@ -9,13 +9,14 @@ package ca.bcit.comp2522.lab03; * @author Trishaan Shetty * @version 1.0.0 */ -public class IPad extends IDevice { +public class IPad extends IDevice +{ - private final static int MAX_OSVERSION_CHARACTERS = 10; - private final static int MIN_OSVERSION_CHARACTERS = 1; + private final static int MAX_OS_VERSION_CHARACTERS = 25; + private final static int MIN_OS_VERSION_CHARACTERS = 1; private final boolean hasCase; - private final String OSVersion; + private final String OSVersion; /** * IPad constructor @@ -24,13 +25,18 @@ public class IPad extends IDevice { */ public IPad( final boolean hasCase, - final String OSVersion + final String OSVersion ) { super("learning"); + this.hasCase = hasCase; - stringValidator(OSVersion, - MIN_OSVERSION_CHARACTERS, - MAX_OSVERSION_CHARACTERS); + + stringValidator( + OSVersion, + MIN_OS_VERSION_CHARACTERS, + MAX_OS_VERSION_CHARACTERS + ); + this.OSVersion = OSVersion; } @@ -46,7 +52,8 @@ public class IPad extends IDevice { * printDetails of IPad including if it has a case * and which operating system version it is running */ - public void printDetails() { + public void printDetails() + { final StringBuilder details; @@ -66,7 +73,8 @@ public class IPad extends IDevice { * @return IPad instance variables */ @Override - public String toString() { + public String toString() + { final StringBuilder details; @@ -89,7 +97,8 @@ public class IPad extends IDevice { * @return if the IPads have the same OS Version */ @Override - public boolean equals(final Object o) { + public boolean equals(final Object o) + { // Ensure object exists if (o == null) { diff --git a/src/code/ca/bcit/comp2522/lab03/IPhone.java b/src/code/ca/bcit/comp2522/lab03/IPhone.java index 8121dc2..5e74661 100644 --- a/src/code/ca/bcit/comp2522/lab03/IPhone.java +++ b/src/code/ca/bcit/comp2522/lab03/IPhone.java @@ -9,12 +9,14 @@ package ca.bcit.comp2522.lab03; * @author Trishaan Shetty * @version 1.0.0 */ -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 int IPHONE_HASH = 11; - private static final int IPHONE_HASH_CODE = 101; +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 int IPHONE_HASH = 11; + private static final int IPHONE_HASH_CODE = 101; private final double remainingPhonePlanMinutes; private final String carrier; @@ -26,16 +28,19 @@ public class IPhone extends IDevice { */ public IPhone( final double remainingPhonePlanMinutes, - final String carrier) - { + final String carrier + ) { super("talking"); minutesValidator(remainingPhonePlanMinutes); this.remainingPhonePlanMinutes = remainingPhonePlanMinutes; - stringValidator(carrier, - MIN_CAREER_CHARACTERS, - MAX_CAREER_CHARACTERS); + stringValidator( + carrier, + MIN_CAREER_CHARACTERS, + MAX_CAREER_CHARACTERS + ); + this.carrier = carrier; } @@ -51,7 +56,8 @@ public class IPhone extends IDevice { * printDetails of IPhone including carrier and remaining * phone plan minutes */ - public void printDetails() { + public void printDetails() + { final StringBuilder details; @@ -71,7 +77,8 @@ public class IPhone extends IDevice { * @return IPhone instance variables */ @Override - public String toString() { + public String toString() + { final StringBuilder iphoneDetails; @@ -93,7 +100,8 @@ public class IPhone extends IDevice { * @return if the IPhone has the same remaining phone plan minutes */ @Override - public boolean equals(final Object o) { + public boolean equals(final Object o) + { // Ensure object exists if (o == null) { @@ -118,7 +126,8 @@ public class IPhone extends IDevice { * @return hash code of IPhone */ @Override - public int hashCode() { + public int hashCode() + { int hash; diff --git a/src/code/ca/bcit/comp2522/lab03/IPhone16.java b/src/code/ca/bcit/comp2522/lab03/IPhone16.java index aa42480..d708e3e 100644 --- a/src/code/ca/bcit/comp2522/lab03/IPhone16.java +++ b/src/code/ca/bcit/comp2522/lab03/IPhone16.java @@ -9,13 +9,15 @@ package ca.bcit.comp2522.lab03; * @author Trishaan Shetty * @version 1.0.0 */ -public class IPhone16 extends IPhone { - private static final int BASE_VARIANT_MEMORY = 128; - private static final int IPHONE_HASH_WITH_HIGH_RES = 103; +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; + final int memoryGB; /** * IPhone16 constructor @@ -51,7 +53,8 @@ public class IPhone16 extends IPhone { * @return IPhone16 instance variables */ @Override - public String toString() { + public String toString() + { final StringBuilder builder; @@ -74,7 +77,8 @@ public class IPhone16 extends IPhone { * @return if the IPhone has the same remaining phone plan minutes and high resolution camera */ @Override - public boolean equals(final Object o) { + public boolean equals(final Object o) + { // Ensure object exists if (o == null) { @@ -105,7 +109,8 @@ public class IPhone16 extends IPhone { * @return hash code of IPhone16 */ @Override - public int hashCode() { + public int hashCode() + { int hash; @@ -127,7 +132,7 @@ public class IPhone16 extends IPhone { public void memoryGBValidator(final int memoryGB) throws IllegalArgumentException { - if (memoryGB % BASE_VARIANT_MEMORY != IS_A_MULTIPLE_OF_BASE_VARIANT) + if (memoryGB % BASE_VARIANT_MEMORY_GB != IS_A_MULTIPLE_OF_BASE_VARIANT) { throw new IllegalArgumentException("Invalid Memory value (GB)"); } diff --git a/src/code/ca/bcit/comp2522/lab03/IPod.java b/src/code/ca/bcit/comp2522/lab03/IPod.java index 79513ce..6cb3f8b 100644 --- a/src/code/ca/bcit/comp2522/lab03/IPod.java +++ b/src/code/ca/bcit/comp2522/lab03/IPod.java @@ -9,13 +9,14 @@ package ca.bcit.comp2522.lab03; * @author Trishaan Shetty * @version 1.0.0 */ -public class IPod extends IDevice { +public class IPod extends IDevice +{ - private static final int NO_SONGS = 0; - private static final int IPOD_HASH = 7; + private static final int NO_SONGS = 0; + private static final int IPOD_HASH = 7; private static final int IPOD_HASH_CODE = 97; - private final int numberOfSongs; + private final int numberOfSongs; private final double maxVolumeDecibels; /** @@ -39,7 +40,8 @@ public class IPod extends IDevice { * printDetails of IPod including number of songs * and max volume in decibels. */ - public void printDetails() { + public void printDetails() + { final StringBuilder details; @@ -67,7 +69,8 @@ public class IPod extends IDevice { * @return IPod instance variables */ @Override - public String toString() { + public String toString() + { final StringBuilder ipodDetails; @@ -89,7 +92,8 @@ public class IPod extends IDevice { * @return if the IPods have the same number of songs */ @Override - public boolean equals(final Object o) { + public boolean equals(final Object o) + { // Ensure object exists if (o == null) { @@ -114,7 +118,8 @@ public class IPod extends IDevice { * @return hash code of IPod */ @Override - public int hashCode() { + public int hashCode() + { int hash;