tidy lab03
This commit is contained in:
6 files changed
+98
-59
No files matched your search
Generated
+23
-22
@@ -5,12 +5,12 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<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/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/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/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/code/ca/bcit/comp2522/lab03/Main.java" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@@ -39,27 +39,27 @@
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"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"
|
||||
<component name="PropertiesComponent">{
|
||||
"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"
|
||||
}
|
||||
}]]></component>
|
||||
}</component>
|
||||
<component name="RecentsManager">
|
||||
<key name="CopyClassDialog.RECENTS_KEY">
|
||||
<recent name="ca.bcit.comp2522.lab02" />
|
||||
@@ -115,7 +115,8 @@
|
||||
<workItem from="1758413771974" duration="332000" />
|
||||
<workItem from="1758425336799" duration="21000" />
|
||||
<workItem from="1758473282464" duration="4563000" />
|
||||
<workItem from="1758570032207" duration="3338000" />
|
||||
<workItem from="1758570032207" duration="7053000" />
|
||||
<workItem from="1759179533296" duration="509000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
|
||||
@@ -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,
|
||||
stringValidator(
|
||||
purpose,
|
||||
MIN_PURPOSE_CHARACTER,
|
||||
MAX_PURPOSE_CHARACTER);
|
||||
MAX_PURPOSE_CHARACTER
|
||||
);
|
||||
|
||||
this.purpose = purpose;
|
||||
}
|
||||
|
||||
@@ -62,9 +67,11 @@ 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,
|
||||
public void stringValidator(
|
||||
final String toBeValidated,
|
||||
final int minCharacterCount,
|
||||
final int maxCharacterCount)
|
||||
final int maxCharacterCount
|
||||
)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,11 @@ 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;
|
||||
@@ -27,10 +28,15 @@ public class IPad extends IDevice {
|
||||
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) {
|
||||
|
||||
@@ -9,7 +9,9 @@ package ca.bcit.comp2522.lab03;
|
||||
* @author Trishaan Shetty
|
||||
* @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 MAX_CAREER_CHARACTERS = 15;
|
||||
private static final double NO_MINUTES_REMAINING = 0.0;
|
||||
@@ -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,
|
||||
stringValidator(
|
||||
carrier,
|
||||
MIN_CAREER_CHARACTERS,
|
||||
MAX_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;
|
||||
|
||||
|
||||
@@ -9,8 +9,10 @@ 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;
|
||||
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;
|
||||
|
||||
@@ -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)");
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@ 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;
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in new issue
Block a user