merge main into braeden/lab04
This commit is contained in:
6 files changed
+227
-76
No files matched your search
Generated
+123
@@ -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">{
|
||||||
|
"associatedIndex": 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">{
|
||||||
|
"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 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>
|
||||||
@@ -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(
|
||||||
MIN_PURPOSE_CHARACTER,
|
purpose,
|
||||||
MAX_PURPOSE_CHARACTER);
|
MIN_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 int minCharacterCount,
|
final String toBeValidated,
|
||||||
final int maxCharacterCount)
|
final int minCharacterCount,
|
||||||
throws IllegalArgumentException
|
final int maxCharacterCount
|
||||||
|
)
|
||||||
|
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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,13 +9,14 @@ 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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IPad constructor
|
* IPad constructor
|
||||||
@@ -24,13 +25,18 @@ public class IPad extends IDevice {
|
|||||||
*/
|
*/
|
||||||
public IPad(
|
public IPad(
|
||||||
final boolean hasCase,
|
final boolean hasCase,
|
||||||
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) {
|
||||||
|
|||||||
@@ -9,12 +9,14 @@ 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 MAX_CAREER_CHARACTERS = 15;
|
|
||||||
private static final double NO_MINUTES_REMAINING = 0.0;
|
private static final int MIN_CAREER_CHARACTERS = 3;
|
||||||
private static final int IPHONE_HASH = 11;
|
private static final int MAX_CAREER_CHARACTERS = 15;
|
||||||
private static final int IPHONE_HASH_CODE = 101;
|
private static final double MIN_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 double remainingPhonePlanMinutes;
|
||||||
private final String carrier;
|
private final String carrier;
|
||||||
@@ -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(
|
||||||
MIN_CAREER_CHARACTERS,
|
carrier,
|
||||||
MAX_CAREER_CHARACTERS);
|
MIN_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,13 +9,13 @@ 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 IS_A_MULTIPLE_OF_BASE_VARIANT = 0;
|
private static final int IPHONE_HASH_WITH_HIGH_RES = 103;
|
||||||
|
|
||||||
final boolean highResolutionCamera;
|
final boolean highResolutionCamera;
|
||||||
final int memoryGB;
|
final int memoryGB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IPhone16 constructor
|
* IPhone16 constructor
|
||||||
@@ -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)");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -9,13 +9,14 @@ 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;
|
||||||
|
|
||||||
private final int numberOfSongs;
|
private final int numberOfSongs;
|
||||||
private final double maxVolumeDecibels;
|
private final double maxVolumeDecibels;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user