tidy lab03

This commit is contained in:
SowinskiBraeden committed 2025-09-29 14:07:32 -07:00
1 parent e77c04ee89
commit af69fe5caa
6 files changed
+98 -59

No files matched your search

+23 -22
View File
@@ -5,12 +5,12 @@
</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/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" /> <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" />
<change beforePath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab03/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab03/Main.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" />
@@ -39,27 +39,27 @@
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent"><![CDATA[{ <component name="PropertiesComponent">{
"keyToString": { &quot;keyToString&quot;: {
"Application.Main.executor": "Run", &quot;Application.Main.executor&quot;: &quot;Run&quot;,
"ModuleVcsDetector.initialDetectionPerformed": "true", &quot;ModuleVcsDetector.initialDetectionPerformed&quot;: &quot;true&quot;,
"RunOnceActivity.ShowReadmeOnStart": "true", &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
"RunOnceActivity.git.unshallow": "true", &quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
"git-widget-placeholder": "main", &quot;git-widget-placeholder&quot;: &quot;main&quot;,
"kotlin-language-version-configured": "true", &quot;kotlin-language-version-configured&quot;: &quot;true&quot;,
"last_opened_file_path": "/home/flami/Projects/comp2522", &quot;last_opened_file_path&quot;: &quot;/home/flami/Projects/comp2522&quot;,
"node.js.detected.package.eslint": "true", &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
"node.js.detected.package.tslint": "true", &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
"node.js.selected.package.eslint": "(autodetect)", &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
"node.js.selected.package.tslint": "(autodetect)", &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
"nodejs_package_manager_path": "npm", &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
"project.structure.last.edited": "Project", &quot;project.structure.last.edited&quot;: &quot;Project&quot;,
"project.structure.proportion": "0.15", &quot;project.structure.proportion&quot;: &quot;0.15&quot;,
"project.structure.side.proportion": "0.2", &quot;project.structure.side.proportion&quot;: &quot;0.2&quot;,
"settings.editor.selected.configurable": "preferences.lookFeel", &quot;settings.editor.selected.configurable&quot;: &quot;preferences.lookFeel&quot;,
"vue.rearranger.settings.migration": "true" &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
} }
}]]></component> }</component>
<component name="RecentsManager"> <component name="RecentsManager">
<key name="CopyClassDialog.RECENTS_KEY"> <key name="CopyClassDialog.RECENTS_KEY">
<recent name="ca.bcit.comp2522.lab02" /> <recent name="ca.bcit.comp2522.lab02" />
@@ -115,7 +115,8 @@
<workItem from="1758413771974" duration="332000" /> <workItem from="1758413771974" duration="332000" />
<workItem from="1758425336799" duration="21000" /> <workItem from="1758425336799" duration="21000" />
<workItem from="1758473282464" duration="4563000" /> <workItem from="1758473282464" duration="4563000" />
<workItem from="1758570032207" duration="3338000" /> <workItem from="1758570032207" duration="7053000" />
<workItem from="1759179533296" duration="509000" />
</task> </task>
<servers /> <servers />
</component> </component>
+18 -8
View File
@@ -9,7 +9,9 @@ package ca.bcit.comp2522.lab03;
* @author Trishaan Shetty * @author Trishaan Shetty
* @version 1.0.0 * @version 1.0.0
*/ */
public abstract class IDevice { public abstract class IDevice
{
private final static int MIN_PURPOSE_CHARACTER = 1; private final static int MIN_PURPOSE_CHARACTER = 1;
private final static int MAX_PURPOSE_CHARACTER = 255; private final static int MAX_PURPOSE_CHARACTER = 255;
@@ -23,9 +25,12 @@ public abstract class IDevice {
public IDevice(final String purpose) public IDevice(final String purpose)
{ {
stringValidator(purpose, stringValidator(
purpose,
MIN_PURPOSE_CHARACTER, MIN_PURPOSE_CHARACTER,
MAX_PURPOSE_CHARACTER); MAX_PURPOSE_CHARACTER
);
this.purpose = purpose; this.purpose = purpose;
} }
@@ -62,9 +67,11 @@ public abstract class IDevice {
* @param minCharacterCount passes the minimum number of characters that can be accepted * @param minCharacterCount passes the minimum number of characters that can be accepted
* as an integer. * as an integer.
* */ * */
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 throws IllegalArgumentException
{ {
@@ -77,9 +84,12 @@ public abstract class IDevice {
if (toBeValidated.isBlank()) { if (toBeValidated.isBlank()) {
throw new IllegalArgumentException("Value cannot be blank"); throw new IllegalArgumentException("Value cannot be blank");
} }
if (toBeValidated.length() < minCharacterCount || toBeValidated.length() > maxCharacterCount) { if (toBeValidated.length() < minCharacterCount ||
throw new IllegalArgumentException("Value length must be between" toBeValidated.length() > maxCharacterCount
+ minCharacterCount + "and " + maxCharacterCount + " characters"); )
{
throw new IllegalArgumentException("Value length must be between" +
minCharacterCount + "and " + maxCharacterCount + " characters");
} }
} }
} }
+18 -9
View File
@@ -9,10 +9,11 @@ package ca.bcit.comp2522.lab03;
* @author Trishaan Shetty * @author Trishaan Shetty
* @version 1.0.0 * @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 MAX_OS_VERSION_CHARACTERS = 25;
private final static int MIN_OSVERSION_CHARACTERS = 1; private final static int MIN_OS_VERSION_CHARACTERS = 1;
private final boolean hasCase; private final boolean hasCase;
private final String OSVersion; private final String OSVersion;
@@ -27,10 +28,15 @@ public class IPad extends IDevice {
final String OSVersion final String OSVersion
) { ) {
super("learning"); super("learning");
this.hasCase = hasCase; this.hasCase = hasCase;
stringValidator(OSVersion,
MIN_OSVERSION_CHARACTERS, stringValidator(
MAX_OSVERSION_CHARACTERS); OSVersion,
MIN_OS_VERSION_CHARACTERS,
MAX_OS_VERSION_CHARACTERS
);
this.OSVersion = OSVersion; this.OSVersion = OSVersion;
} }
@@ -46,7 +52,8 @@ public class IPad extends IDevice {
* printDetails of IPad including if it has a case * printDetails of IPad including if it has a case
* and which operating system version it is running * and which operating system version it is running
*/ */
public void printDetails() { public void printDetails()
{
final StringBuilder details; final StringBuilder details;
@@ -66,7 +73,8 @@ public class IPad extends IDevice {
* @return IPad instance variables * @return IPad instance variables
*/ */
@Override @Override
public String toString() { public String toString()
{
final StringBuilder details; final StringBuilder details;
@@ -89,7 +97,8 @@ public class IPad extends IDevice {
* @return if the IPads have the same OS Version * @return if the IPads have the same OS Version
*/ */
@Override @Override
public boolean equals(final Object o) { public boolean equals(final Object o)
{
// Ensure object exists // Ensure object exists
if (o == null) { if (o == null) {
+18 -9
View File
@@ -9,7 +9,9 @@ package ca.bcit.comp2522.lab03;
* @author Trishaan Shetty * @author Trishaan Shetty
* @version 1.0.0 * @version 1.0.0
*/ */
public class IPhone extends IDevice { 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 NO_MINUTES_REMAINING = 0.0;
@@ -26,16 +28,19 @@ public class IPhone extends IDevice {
*/ */
public IPhone( public IPhone(
final double remainingPhonePlanMinutes, final double remainingPhonePlanMinutes,
final String carrier) final String carrier
{ ) {
super("talking"); super("talking");
minutesValidator(remainingPhonePlanMinutes); minutesValidator(remainingPhonePlanMinutes);
this.remainingPhonePlanMinutes = remainingPhonePlanMinutes; this.remainingPhonePlanMinutes = remainingPhonePlanMinutes;
stringValidator(carrier, stringValidator(
carrier,
MIN_CAREER_CHARACTERS, MIN_CAREER_CHARACTERS,
MAX_CAREER_CHARACTERS); MAX_CAREER_CHARACTERS
);
this.carrier = carrier; this.carrier = carrier;
} }
@@ -51,7 +56,8 @@ public class IPhone extends IDevice {
* printDetails of IPhone including carrier and remaining * printDetails of IPhone including carrier and remaining
* phone plan minutes * phone plan minutes
*/ */
public void printDetails() { public void printDetails()
{
final StringBuilder details; final StringBuilder details;
@@ -71,7 +77,8 @@ public class IPhone extends IDevice {
* @return IPhone instance variables * @return IPhone instance variables
*/ */
@Override @Override
public String toString() { public String toString()
{
final StringBuilder iphoneDetails; final StringBuilder iphoneDetails;
@@ -93,7 +100,8 @@ public class IPhone extends IDevice {
* @return if the IPhone has the same remaining phone plan minutes * @return if the IPhone has the same remaining phone plan minutes
*/ */
@Override @Override
public boolean equals(final Object o) { public boolean equals(final Object o)
{
// Ensure object exists // Ensure object exists
if (o == null) { if (o == null) {
@@ -118,7 +126,8 @@ public class IPhone extends IDevice {
* @return hash code of IPhone * @return hash code of IPhone
*/ */
@Override @Override
public int hashCode() { public int hashCode()
{
int hash; int hash;
+11 -6
View File
@@ -9,8 +9,10 @@ package ca.bcit.comp2522.lab03;
* @author Trishaan Shetty * @author Trishaan Shetty
* @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 = 128; {
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; private static final int IS_A_MULTIPLE_OF_BASE_VARIANT = 0;
@@ -51,7 +53,8 @@ public class IPhone16 extends IPhone {
* @return IPhone16 instance variables * @return IPhone16 instance variables
*/ */
@Override @Override
public String toString() { public String toString()
{
final StringBuilder builder; 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 * @return if the IPhone has the same remaining phone plan minutes and high resolution camera
*/ */
@Override @Override
public boolean equals(final Object o) { public boolean equals(final Object o)
{
// Ensure object exists // Ensure object exists
if (o == null) { if (o == null) {
@@ -105,7 +109,8 @@ public class IPhone16 extends IPhone {
* @return hash code of IPhone16 * @return hash code of IPhone16
*/ */
@Override @Override
public int hashCode() { public int hashCode()
{
int hash; int hash;
@@ -127,7 +132,7 @@ public class IPhone16 extends IPhone {
public void memoryGBValidator(final int memoryGB) public void memoryGBValidator(final int memoryGB)
throws IllegalArgumentException 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)"); throw new IllegalArgumentException("Invalid Memory value (GB)");
} }
+10 -5
View File
@@ -9,7 +9,8 @@ package ca.bcit.comp2522.lab03;
* @author Trishaan Shetty * @author Trishaan Shetty
* @version 1.0.0 * @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 NO_SONGS = 0;
private static final int IPOD_HASH = 7; private static final int IPOD_HASH = 7;
@@ -39,7 +40,8 @@ public class IPod extends IDevice {
* printDetails of IPod including number of songs * printDetails of IPod including number of songs
* and max volume in decibels. * and max volume in decibels.
*/ */
public void printDetails() { public void printDetails()
{
final StringBuilder details; final StringBuilder details;
@@ -67,7 +69,8 @@ public class IPod extends IDevice {
* @return IPod instance variables * @return IPod instance variables
*/ */
@Override @Override
public String toString() { public String toString()
{
final StringBuilder ipodDetails; final StringBuilder ipodDetails;
@@ -89,7 +92,8 @@ public class IPod extends IDevice {
* @return if the IPods have the same number of songs * @return if the IPods have the same number of songs
*/ */
@Override @Override
public boolean equals(final Object o) { public boolean equals(final Object o)
{
// Ensure object exists // Ensure object exists
if (o == null) { if (o == null) {
@@ -114,7 +118,8 @@ public class IPod extends IDevice {
* @return hash code of IPod * @return hash code of IPod
*/ */
@Override @Override
public int hashCode() { public int hashCode()
{
int hash; int hash;