diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5468d9e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/out/*
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 4c54846..428d324 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,4 +1,6 @@
-
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 40849de..beb1c4d 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -6,11 +6,6 @@
-
-
-
-
-
@@ -39,31 +34,52 @@
- {
- "keyToString": {
- "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"
+
+}]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -86,6 +102,11 @@
+
+
+
+
+
diff --git a/src/code/ca/bcit/comp2522/lab03/IDevice.java b/src/code/ca/bcit/comp2522/lab03/IDevice.java
new file mode 100644
index 0000000..f5a22bc
--- /dev/null
+++ b/src/code/ca/bcit/comp2522/lab03/IDevice.java
@@ -0,0 +1,20 @@
+package ca.bcit.comp2522.lab03;
+
+public abstract class IDevice {
+ private final String purpose;
+
+ IDevice(final String purpose) {
+ this.purpose = purpose;
+ }
+
+ abstract void printDetails();
+
+ protected String getPurpose() {
+ return this.purpose;
+ }
+
+ @Override
+ public String toString() {
+ return this.purpose;
+ }
+}
diff --git a/src/code/ca/bcit/comp2522/lab03/IPad.java b/src/code/ca/bcit/comp2522/lab03/IPad.java
new file mode 100644
index 0000000..27eba40
--- /dev/null
+++ b/src/code/ca/bcit/comp2522/lab03/IPad.java
@@ -0,0 +1,34 @@
+package ca.bcit.comp2522.lab03;
+
+public class IPad extends IDevice {
+ private final boolean hasCase;
+ private final String OSVersion;
+
+ IPad(
+ final boolean hasCase,
+ final String OSVersion
+ ) {
+ super("learning");
+
+ this.hasCase = hasCase;
+ this.OSVersion = OSVersion;
+ }
+
+ protected void printDetails() {
+ final StringBuilder details;
+
+ details = new StringBuilder();
+
+ details.append("Has case: ");
+ details.append(this.hasCase);
+ details.append(" OS Version: ");
+ details.append(this.OSVersion);
+
+ System.out.println(details.toString());
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " " + this.hasCase + " " + this.OSVersion;
+ }
+}
diff --git a/src/code/ca/bcit/comp2522/lab03/IPhone.java b/src/code/ca/bcit/comp2522/lab03/IPhone.java
new file mode 100644
index 0000000..fbf9092
--- /dev/null
+++ b/src/code/ca/bcit/comp2522/lab03/IPhone.java
@@ -0,0 +1,34 @@
+package ca.bcit.comp2522.lab03;
+
+public class IPhone extends IDevice {
+ private final double remainingPhonePlanMinutes;
+ private final String carrier;
+
+ IPhone(
+ final double remainingPhonePlanMinutes,
+ final String carrier
+ ) {
+ super("talking");
+
+ this.remainingPhonePlanMinutes = remainingPhonePlanMinutes;
+ this.carrier = carrier;
+ }
+
+ protected void printDetails() {
+ final StringBuilder details;
+
+ details = new StringBuilder();
+
+ details.append(this.remainingPhonePlanMinutes);
+ details.append(" remaining minutes (");
+ details.append(this.carrier);
+ details.append(")");
+
+ System.out.println(details.toString());
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " " + this.remainingPhonePlanMinutes + " " + this.carrier;
+ }
+}
diff --git a/src/code/ca/bcit/comp2522/lab03/IPhone16.java b/src/code/ca/bcit/comp2522/lab03/IPhone16.java
new file mode 100644
index 0000000..6c8cf65
--- /dev/null
+++ b/src/code/ca/bcit/comp2522/lab03/IPhone16.java
@@ -0,0 +1,18 @@
+package ca.bcit.comp2522.lab03;
+
+public class IPhone16 extends IPhone {
+ final boolean highResolutionCamera;
+ final int memoryGB;
+
+ IPhone16(
+ final double remainingPhonePlanMinutes,
+ final String carrier,
+ final boolean highResolutionCamera,
+ final int memoryGB
+ ) {
+ super(remainingPhonePlanMinutes, carrier);
+
+ this.highResolutionCamera = highResolutionCamera;
+ this.memoryGB = memoryGB;
+ }
+}
diff --git a/src/code/ca/bcit/comp2522/lab03/IPod.java b/src/code/ca/bcit/comp2522/lab03/IPod.java
new file mode 100644
index 0000000..f18c67a
--- /dev/null
+++ b/src/code/ca/bcit/comp2522/lab03/IPod.java
@@ -0,0 +1,34 @@
+package ca.bcit.comp2522.lab03;
+
+public class IPod extends IDevice {
+ private final int numberOfSongs;
+ private final double maxVolumeDecibels;
+
+ IPod(
+ final int numberOfSongs,
+ final double maxVolumeDecibels
+ ) {
+ super("music");
+
+ this.numberOfSongs = numberOfSongs;
+ this.maxVolumeDecibels = maxVolumeDecibels;
+ }
+
+ protected void printDetails() {
+ final StringBuilder details;
+
+ details = new StringBuilder();
+
+ details.append(this.numberOfSongs);
+ details.append(" songs, ");
+ details.append(this.maxVolumeDecibels);
+ details.append(" dB.");
+
+ System.out.println(details.toString());
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " " + this.numberOfSongs + " " + this.maxVolumeDecibels;
+ }
+}
diff --git a/src/code/ca/bcit/comp2522/lab03/Main.java b/src/code/ca/bcit/comp2522/lab03/Main.java
new file mode 100644
index 0000000..005441d
--- /dev/null
+++ b/src/code/ca/bcit/comp2522/lab03/Main.java
@@ -0,0 +1,100 @@
+package ca.bcit.comp2522.lab03;
+
+public class Main {
+ public static void main(final String[] args) {
+ // Create IPod objects
+ final IPod ipod1;
+ final IPod ipod2;
+ final IPod ipod3;
+
+ ipod1 = new IPod(300, 80.0); // 300 songs, max volume 80.0 dB
+ ipod2 = new IPod(400, 85.0); // 400 songs, max volume 85.0 dB
+ ipod3 = new IPod(300, 70.0); // 300 songs, max volume 70.0 dB
+
+ // Test equality and inequality for IPod
+ System.out.println("IPod Equality Test:");
+ if (!ipod1.equals(ipod2)) {
+ System.out.println("CORRECT: ipod1 is not equal to ipod2");
+ } else {
+ System.out.println("INCORRECT: ipod1 should not be equal to ipod2");
+ }
+
+ if (ipod1.equals(ipod3)) {
+ System.out.println("CORRECT: ipod1 is equal to ipod3");
+ } else {
+ System.out.println("INCORRECT: ipod1 should be equal to ipod3");
+ }
+
+ System.out.println();
+
+ // Create IPad objects
+ final IPad ipad1;
+ final IPad ipad2;
+ final IPad ipad3;
+
+ ipad1 = new IPad(true, "iPadOS 15"); // Has case, OS version iPadOS 15
+ ipad2 = new IPad(false, "iPadOS 14"); // No case, OS version iPadOS 14
+ ipad3 = new IPad(true, "iPadOS 15"); // Has case, OS version iPadOS 15
+
+ // Test equality and inequality for IPad
+ System.out.println("IPad Equality Test:");
+
+ if (!ipad1.equals(ipad2)) {
+ System.out.println("CORRECT: ipad1 is not equal to ipad2");
+ } else {
+ System.out.println("INCORRECT: ipad1 should not be equal to ipad2");
+ }
+
+ if (ipad1.equals(ipad3)) {
+ System.out.println("CORRECT: ipad1 is equal to ipad3");
+ } else {
+ System.out.println("INCORRECT: ipad1 should be equal to ipad3");
+ }
+ System.out.println();
+
+ // Create IPhone objects
+ final IPhone iphone1;
+ final IPhone iphone2;
+ final IPhone iphone3;
+ iphone1 = new IPhone(120.0, "Verizon"); // 120 minutes, carrier Verizon
+ iphone2 = new IPhone(180.0, "T-Mobile"); // 180 minutes, carrier T-Mobile
+ iphone3 = new IPhone(120.0, "AT&T"); // 120 minutes, carrier AT&T
+
+ // Test equality and inequality for IPhone
+ System.out.println("IPhone Equality Test:");
+ if (!iphone1.equals(iphone2)) {
+ System.out.println("CORRECT: iphone1 is not equal to iphone2");
+ } else {
+ System.out.println("INCORRECT: iphone1 should not be equal to iphone2");
+ }
+ if (iphone1.equals(iphone3)) {
+ System.out.println("CORRECT: iphone1 is equal to iphone3");
+ } else {
+ System.out.println("INCORRECT: iphone1 should be equal to iphone3");
+ }
+ System.out.println();
+
+ // Create IPhone16 objects
+ final IPhone16 iphone16_1;
+ final IPhone16 iphone16_2;
+ final IPhone16 iphone16_3;
+
+ iphone16_1 = new IPhone16(100.0, "Verizon", true, 512); // 100 minutes, high-res camera, 512 GB
+ iphone16_2 = new IPhone16(100.0, "Verizon", true, 256); // 100 minutes, high-res camera, 256 GB
+ iphone16_3 = new IPhone16(100.0, "Verizon", false, 512); // 100 minutes, no high-res camera, 512 GB
+
+ // Test equality and inequality for IPhone16
+ System.out.println("IPhone16 Equality Test:");
+ if (iphone16_1.equals(iphone16_2)) {
+ System.out.println("CORRECT: iphone16_1 is equal to iphone16_2");
+ } else {
+ System.out.println("INCORRECT: iphone16_1 should be equal to iphone16_2");
+ }
+ if (!iphone16_1.equals(iphone16_3)) {
+ System.out.println("CORRECT: iphone16_1 is not equal to iphone16_3");
+ } else {
+ System.out.println("INCORRECT: iphone16_1 should not be equal to iphone16_3");
+ }
+ System.out.println();
+ }
+}