merge main into braeden/lab04

This commit is contained in:
SowinskiBraeden committed 2025-10-03 20:46:59 -07:00
commit b5a9c79b83
6 files changed
+213 -62

No files matched your search

+123
View File
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="4481728b-524b-48ee-9d70-e414a15f05bd" name="Changes" comment="">
<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/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" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Exception" />
<option value="Class" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectColorInfo">{
&quot;associatedIndex&quot;: 1
}</component>
<component name="ProjectId" id="32FqHctBhV1BOJd5cgky1d5ERVo" />
<component name="ProjectLevelVcsManager">
<ConfirmationsSetting value="1" id="Add" />
</component>
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;Application.Main.executor&quot;: &quot;Run&quot;,
&quot;ModuleVcsDetector.initialDetectionPerformed&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;main&quot;,
&quot;kotlin-language-version-configured&quot;: &quot;true&quot;,
&quot;last_opened_file_path&quot;: &quot;/home/flami/Projects/comp2522&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;project.structure.last.edited&quot;: &quot;Project&quot;,
&quot;project.structure.proportion&quot;: &quot;0.15&quot;,
&quot;project.structure.side.proportion&quot;: &quot;0.2&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;preferences.lookFeel&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}
}</component>
<component name="RecentsManager">
<key name="CopyClassDialog.RECENTS_KEY">
<recent name="ca.bcit.comp2522.lab02" />
</key>
</component>
<component name="RunManager">
<configuration name="Main" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="ca.bcit.comp2522.lab03.Main" />
<module name="comp2522" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="ca.bcit.comp2522.lab03.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<recent_temporary>
<list>
<item itemvalue="Application.Main" />
</list>
</recent_temporary>
</component>
<component name="SharedIndexes">
<attachedChunks>
<set>
<option value="bundled-jdk-9823dce3aa75-bf35d07a577b-intellij.indexing.shared.core-IU-252.26199.169" />
<option value="bundled-js-predefined-d6986cc7102b-9c94529fcfe0-JavaScript-IU-252.26199.169" />
</set>
</attachedChunks>
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="4481728b-524b-48ee-9d70-e414a15f05bd" name="Changes" comment="" />
<created>1757026582895</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1757026582895</updated>
<workItem from="1757978409399" duration="133000" />
<workItem from="1757978555342" duration="50000" />
<workItem from="1757978628819" duration="106000" />
<workItem from="1757978741081" duration="333000" />
<workItem from="1757986074841" duration="318000" />
<workItem from="1758045661655" duration="660000" />
<workItem from="1758156443615" duration="6374000" />
<workItem from="1758221692281" duration="40000" />
<workItem from="1758221863793" duration="810000" />
<workItem from="1758254368145" duration="997000" />
<workItem from="1758294307794" duration="4368000" />
<workItem from="1758342126924" duration="1015000" />
<workItem from="1758413771974" duration="332000" />
<workItem from="1758425336799" duration="21000" />
<workItem from="1758473282464" duration="4563000" />
<workItem from="1758570032207" duration="7053000" />
<workItem from="1759179533296" duration="997000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
</project>
+22 -8
View File
@@ -7,9 +7,12 @@ package ca.bcit.comp2522.lab03;
* @author Braeden Sowinski * @author Braeden Sowinski
* @author Nicolas Agostini * @author Nicolas Agostini
* @author Trishaan Shetty * @author Trishaan Shetty
* * @author Calvin Arifianto
* @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 +26,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,24 +68,32 @@ 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
{ {
if (toBeValidated == null) { if (toBeValidated == null) {
throw new IllegalArgumentException("Value cannot be null"); throw new IllegalArgumentException("Value cannot be null");
} }
if (toBeValidated.isEmpty()) { if (toBeValidated.isEmpty()) {
throw new IllegalArgumentException("Value cannot be empty"); throw new IllegalArgumentException("Value cannot be empty");
} }
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) {
throw new IllegalArgumentException("Value length must be between" if (toBeValidated.length() < minCharacterCount ||
+ minCharacterCount + "and " + maxCharacterCount + " characters"); toBeValidated.length() > maxCharacterCount
)
{
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) {
+28 -15
View File
@@ -9,10 +9,12 @@ 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 MIN_MINUTES_REMAINING = 0.0;
private static final int IPHONE_HASH = 11; private static final int IPHONE_HASH = 11;
private static final int IPHONE_HASH_CODE = 101; private static final int IPHONE_HASH_CODE = 101;
@@ -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;
@@ -128,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");
} }
} }
} }
+9 -21
View File
@@ -9,10 +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 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;
@@ -34,7 +34,6 @@ public class IPhone16 extends IPhone {
this.highResolutionCamera = highResolutionCamera; this.highResolutionCamera = highResolutionCamera;
memoryGBValidator(memoryGB);
this.memoryGB = memoryGB; this.memoryGB = memoryGB;
} }
@@ -51,7 +50,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 +74,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 +106,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;
@@ -118,18 +120,4 @@ public class IPhone16 extends IPhone {
return hash; 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 != IS_A_MULTIPLE_OF_BASE_VARIANT)
{
throw new IllegalArgumentException("Invalid Memory value (GB)");
}
}
} }
+13 -9
View File
@@ -9,9 +9,10 @@ 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 MIN_SONGS = 0;
private static final int IPOD_HASH = 7; private static final int IPOD_HASH = 7;
private static final int IPOD_HASH_CODE = 97; private static final int IPOD_HASH_CODE = 97;
@@ -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;
@@ -130,11 +135,10 @@ public class IPod extends IDevice {
* @param songNumber passes the value of the number of songs. * @param songNumber passes the value of the number of songs.
* */ * */
public void numberOfSongsValidator(final int songNumber) 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);
} }
} }
} }