From b3ad2fefce1d861f2fba461d54288ceb5b4967aa Mon Sep 17 00:00:00 2001 From: Alex4386 Date: Mon, 8 Apr 2024 11:31:45 +0900 Subject: [PATCH] chore: add homeworks --- .../java/me/alex4386/gachon/sw14462/Main.java | 2 +- .../alex4386/gachon/sw14462/day11/Main.java | 18 ++++ .../gachon/sw14462/day11/ex6_2a/Main.java | 18 ++++ .../gachon/sw14462/day11/ex6_2a/Suit.java | 15 +++ .../gachon/sw14462/day11/ex6_2b/Main.java | 7 ++ .../gachon/sw14462/day11/ex6_2b/Time.java | 57 ++++++++++++ .../gachon/sw14462/day11/ex6_2b/TimeTest.java | 38 ++++++++ .../sw14462/day11/ex6_4/Characteristic.java | 69 ++++++++++++++ .../day11/ex6_4/CharacteristicTest.java | 40 ++++++++ .../gachon/sw14462/day11/ex6_4/Main.java | 8 ++ .../gachon/sw14462/day11/ex6_6/Main.java | 7 ++ .../gachon/sw14462/day11/ex6_6/Person.java | 93 +++++++++++++++++++ .../sw14462/day11/ex6_6/PersonTest.java | 58 ++++++++++++ .../gachon/sw14462/day11/ex6_7/Main.java | 7 ++ .../sw14462/day11/ex6_7/Temperature.java | 76 +++++++++++++++ .../sw14462/day11/ex6_7/TemperatureTest.java | 53 +++++++++++ 16 files changed, 565 insertions(+), 1 deletion(-) create mode 100644 src/main/java/me/alex4386/gachon/sw14462/day11/Main.java create mode 100644 src/main/java/me/alex4386/gachon/sw14462/day11/ex6_2a/Main.java create mode 100644 src/main/java/me/alex4386/gachon/sw14462/day11/ex6_2a/Suit.java create mode 100644 src/main/java/me/alex4386/gachon/sw14462/day11/ex6_2b/Main.java create mode 100644 src/main/java/me/alex4386/gachon/sw14462/day11/ex6_2b/Time.java create mode 100644 src/main/java/me/alex4386/gachon/sw14462/day11/ex6_2b/TimeTest.java create mode 100644 src/main/java/me/alex4386/gachon/sw14462/day11/ex6_4/Characteristic.java create mode 100644 src/main/java/me/alex4386/gachon/sw14462/day11/ex6_4/CharacteristicTest.java create mode 100644 src/main/java/me/alex4386/gachon/sw14462/day11/ex6_4/Main.java create mode 100644 src/main/java/me/alex4386/gachon/sw14462/day11/ex6_6/Main.java create mode 100644 src/main/java/me/alex4386/gachon/sw14462/day11/ex6_6/Person.java create mode 100644 src/main/java/me/alex4386/gachon/sw14462/day11/ex6_6/PersonTest.java create mode 100644 src/main/java/me/alex4386/gachon/sw14462/day11/ex6_7/Main.java create mode 100644 src/main/java/me/alex4386/gachon/sw14462/day11/ex6_7/Temperature.java create mode 100644 src/main/java/me/alex4386/gachon/sw14462/day11/ex6_7/TemperatureTest.java diff --git a/src/main/java/me/alex4386/gachon/sw14462/Main.java b/src/main/java/me/alex4386/gachon/sw14462/Main.java index 5ebfda1..34c44c4 100644 --- a/src/main/java/me/alex4386/gachon/sw14462/Main.java +++ b/src/main/java/me/alex4386/gachon/sw14462/Main.java @@ -5,7 +5,7 @@ import java.util.*; public class Main { - public static String currentTarget = "day10"; + public static String currentTarget = "day11"; public static boolean fallbackToLatest = true; public static Map> getAvailableTargetClassNames() { diff --git a/src/main/java/me/alex4386/gachon/sw14462/day11/Main.java b/src/main/java/me/alex4386/gachon/sw14462/day11/Main.java new file mode 100644 index 0000000..b02f5ab --- /dev/null +++ b/src/main/java/me/alex4386/gachon/sw14462/day11/Main.java @@ -0,0 +1,18 @@ +package me.alex4386.gachon.sw14462.day11; + +import me.alex4386.gachon.sw14462.utils.Chainloader; + +public class Main { + public static String chainloadTarget = "ex6_7"; + + public static void main(String[] args) throws Throwable { + String packageName = Main.class.getPackage().getName(); + String chainLoadTargetClass = packageName + "." + chainloadTarget + ".Main"; + + try { + Chainloader.chainloadTarget(chainLoadTargetClass, args); + } catch (Exception e) { + throw e; + } + } +} diff --git a/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_2a/Main.java b/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_2a/Main.java new file mode 100644 index 0000000..8a7ec3e --- /dev/null +++ b/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_2a/Main.java @@ -0,0 +1,18 @@ +package me.alex4386.gachon.sw14462.day11.ex6_2a; + +public class Main { + public static void main(String args[]) { + Suit cardSuit = Suit.SPADES; + System.out.println("cardSuit = Suit.SPADES"); + + System.out.println("cardSuit.ordinal() = " + cardSuit.ordinal()); + System.out.println("cardSuit.equals(Suit.CLUBS) = " + cardSuit.equals(Suit.CLUBS)); + System.out.println("cardSuit.compareTo(Suit.CLUBS) = " + cardSuit.compareTo(Suit.CLUBS)); + + System.out.println("Suit.valueOf(\"CLUBS\") = " + Suit.valueOf("CLUBS")); + System.out.println("Suit.valueOf(cardSuit.toString()) = " + Suit.valueOf(cardSuit.toString())); + + System.out.println("cardSuit.getColor() = " + cardSuit.getColor()); + System.out.println("cardSuit.toString() = " + cardSuit.toString()); + } +} diff --git a/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_2a/Suit.java b/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_2a/Suit.java new file mode 100644 index 0000000..cc553e4 --- /dev/null +++ b/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_2a/Suit.java @@ -0,0 +1,15 @@ +package me.alex4386.gachon.sw14462.day11.ex6_2a; + +public enum Suit { + CLUBS("black"), DIAMONDS("red"), HEARTS("red"), SPADES("black"); + + private final String color; + + private Suit(String suitColor) { + this.color = suitColor; + } + + public String getColor() { + return this.color; + } +} diff --git a/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_2b/Main.java b/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_2b/Main.java new file mode 100644 index 0000000..3281d29 --- /dev/null +++ b/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_2b/Main.java @@ -0,0 +1,7 @@ +package me.alex4386.gachon.sw14462.day11.ex6_2b; + +public class Main { + public static void main(String[] args) { + TimeTest.main(args); + } +} diff --git a/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_2b/Time.java b/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_2b/Time.java new file mode 100644 index 0000000..45c6714 --- /dev/null +++ b/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_2b/Time.java @@ -0,0 +1,57 @@ +package me.alex4386.gachon.sw14462.day11.ex6_2b; + +public class Time { + private int hours; + private int minute; + + public Time() { + this(0,0); + } + + public Time(int hours, int minute) { + if (Time.isValid(hours, minute)) { + this.hours = hours; + this.minute = minute; + } else { + throw new IllegalArgumentException("Invalid time"); + } + } + + public Time(int hours, int minute, boolean isPM) throws IllegalArgumentException { + this(hours + (isPM ? 12 : 0), minute); + } + + public static boolean isValid(int hours, int minute) { + return (hours >= 0 && hours <= 23) && + (minute >= 0 && minute <= 59); + } + + public String getTime24() { + return String.format("%02d%02d", this.hours, this.minute); + } + + public String getTime12() { + return String.format("%d:%02d %s", this.hours % 12, this.minute, this.hours >= 12 ? "PM" : "AM"); + } + + public void setTime(int hours, int minute) { + if (Time.isValid(hours, minute)) { + this.hours = hours; + this.minute = minute; + } else { + throw new IllegalArgumentException("Invalid time"); + } + } + + public void setTime2(int hours, int minute, boolean isPM) { + // seems not intended when PM=true and hours=12, + // but it's not mentioned in the requirement + int hours24 = hours + (isPM ? 12 : 0); + this.setTime(hours24, minute); + } + + @Override + public String toString() { + return String.format("%02d:%02d", this.hours, this.minute); + } +} diff --git a/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_2b/TimeTest.java b/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_2b/TimeTest.java new file mode 100644 index 0000000..e1d7130 --- /dev/null +++ b/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_2b/TimeTest.java @@ -0,0 +1,38 @@ +package me.alex4386.gachon.sw14462.day11.ex6_2b; + +public class TimeTest { + public static void main(String[] args) { + System.out.println("Test scenario 1: valid time (12:49)"); + boolean result = Time.isValid(12, 49); + System.out.println("Expected: true"); + System.out.println("Actual: " + result); + + System.out.println("Test scenario 2: invalid time (24:00)"); + result = Time.isValid(24, 0); + System.out.println("Expected: false"); + System.out.println("Actual: " + result); + + System.out.println("Test scenario 3: invalid time (12:60)"); + result = Time.isValid(12, 60); + System.out.println("Expected: false"); + System.out.println("Actual: " + result); + + System.out.println("Test scenario 4: Initialize Time to (05:49)"); + Time time = new Time(5, 49); + System.out.println("Expected: 05:49"); + System.out.println("Actual: " + time.toString()); + + System.out.println("Test scenario 5: Initialize Time with alternative constructor to 05:49 PM (17:49)"); + time = new Time(5, 49, true); + System.out.println("Expected: 17:49"); + System.out.println("Actual: " + time.toString()); + + System.out.println("Test scenario 6: Test time.getTime24() is 17:49"); + System.out.println("Expected: 1749"); + System.out.println("Actual: " + time.getTime24()); + + System.out.println("Test scenario 7: Test time.getTime12() is 5:49 PM"); + System.out.println("Expected: 5:49 PM"); + System.out.println("Actual: " + time.getTime12()); + } +} diff --git a/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_4/Characteristic.java b/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_4/Characteristic.java new file mode 100644 index 0000000..1d33bdc --- /dev/null +++ b/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_4/Characteristic.java @@ -0,0 +1,69 @@ +package me.alex4386.gachon.sw14462.day11.ex6_4; + +import java.util.Scanner; + +public class Characteristic { + + private String description; + private int rating; + + public Characteristic(String description) { + this.description = description; + this.rating = 0; + } + + private boolean isValid(int aRating) { + // range check + return aRating >= 1 && aRating <= 10; + } + + public void setRating(int aRating) { + if (this.isValid(aRating)) { + this.rating = aRating; + } else { + throw new IllegalArgumentException("Invalid rating"); + } + } + + public void setRating() { + Scanner scanner = new Scanner(System.in); + + System.out.println("Characteristic: "+this.description); + System.out.print("Enter a rating: "); + int aRating = scanner.nextInt(); + + try { + this.setRating(aRating); + } catch (IllegalArgumentException e) { + System.err.println("Invalid Rating! Please enter a rating between 1 and 10."); + } + } + + + public String getDescription() { + return this.description; + } + + public int getRating() { + return this.rating; + } + + private double getCompatibilityMeasure(Characteristic otherRating) { + // early return to catch if it hasn't rated yet. + if (this.rating == 0 || otherRating.rating == 0) { + return 0.0; + } + + return 1.0 - (Math.pow(this.rating - otherRating.rating, 2) / 81.0); + } + + private boolean isMatch(Characteristic otherRating) { + return this.description.equals(otherRating.description); + } + + public double getCompatibility(Characteristic otherRating) { + return this.isMatch(otherRating) ? + this.getCompatibilityMeasure(otherRating) : + 0.0; + } +} diff --git a/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_4/CharacteristicTest.java b/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_4/CharacteristicTest.java new file mode 100644 index 0000000..319491b --- /dev/null +++ b/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_4/CharacteristicTest.java @@ -0,0 +1,40 @@ +package me.alex4386.gachon.sw14462.day11.ex6_4; + +public class CharacteristicTest { + public static void main(String[] args) { + Characteristic character1 = new Characteristic("Sample Description for Characteristic 1, 3 and 4"); + Characteristic character2 = new Characteristic("Sample Description for Characteristic 2"); + Characteristic character3 = new Characteristic("Sample Description for Characteristic 1, 3 and 4"); + Characteristic character4 = new Characteristic("Sample Description for Characteristic 1, 3 and 4"); + + System.out.println("character1.getDescription() = " + character1.getDescription()); + System.out.println("character2.getDescription() = " + character2.getDescription()); + System.out.println("character3.getDescription() = " + character3.getDescription()); + System.out.println("character4.getDescription() = " + character4.getDescription()); + + System.out.println("Requesting rating for character1..."); + character1.setRating(); + System.out.println("character1.getRating() = " + character1.getRating()); + + if (character1.getRating() == 0) { + System.out.println("Due to invalid rating input, character1's rating is still 0. Provisioning instance's rating to 5."); + character1.setRating(5); + } + + System.out.println("Setting rating for character2 to "+character1.getRating()); + character2.setRating(character1.getRating()); + System.out.println("character2.getRating() = " + character2.getRating()); + + System.out.println("Setting rating for character3 to "+character1.getRating()); + character3.setRating(character1.getRating()); + System.out.println("character3.getRating() = " + character2.getRating()); + + System.out.println("Setting rating for character4 to 9"); + character4.setRating(1); + System.out.println("character4.getRating() = " + character4.getRating()); + + System.out.println("character1.getCompatibility(character2) = " + character1.getCompatibility(character2)); + System.out.println("character1.getCompatibility(character3) = " + character1.getCompatibility(character3)); + System.out.println("character1.getCompatibility(character4) = " + character1.getCompatibility(character4)); + } +} diff --git a/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_4/Main.java b/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_4/Main.java new file mode 100644 index 0000000..26d0726 --- /dev/null +++ b/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_4/Main.java @@ -0,0 +1,8 @@ +package me.alex4386.gachon.sw14462.day11.ex6_4; + +public class Main { + + public static void main(String[] args) { + CharacteristicTest.main(args); + } +} diff --git a/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_6/Main.java b/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_6/Main.java new file mode 100644 index 0000000..e20d431 --- /dev/null +++ b/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_6/Main.java @@ -0,0 +1,7 @@ +package me.alex4386.gachon.sw14462.day11.ex6_6; + +public class Main { + public static void main(String[] args) { + PersonTest.main(args); + } +} diff --git a/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_6/Person.java b/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_6/Person.java new file mode 100644 index 0000000..0cf2877 --- /dev/null +++ b/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_6/Person.java @@ -0,0 +1,93 @@ +package me.alex4386.gachon.sw14462.day11.ex6_6; + +public class Person +{ + private String name; + private int age; + + /* Start of Exercise 10 */ + public Person() { + this("No name yet", 0); + } + + public Person(String name, int age) { + this.name = name; + this.age = age; + } + + + public static Person createAdult() { + return new Person("An adult", 21); + } + /* End of Exercise 10 */ + + /* From the Self-Test Question 16 */ + + /* + // Commented-out since due to duplicate requirement + // from Programming Project 6 + + public void setName(String newName) + { + name = newName; + } + + public void setAge(int newAge) + { + if (newAge >= 0) + age = newAge; + else + { + System.out.println("ERROR: Age is " + + "negative."); + System.exit(0); + } + } + */ + + public void setPerson(String newName, int newAge) + { + setName(newName); + setAge(newAge); + } + /* End of Self-Test Question 16 */ + + + /* Start of Programming projects 6 */ + public String getName() { + return this.name; + } + + public int getAge() { + return this.age; + } + + public void setName(String first, String last) { + this.name = first + " " + last; + } + + public void setName(String name) { + this.name = name; + } + + public void setAge(int age) { + if (this.age < 0) throw new IllegalArgumentException("Age cannot be negative"); + this.age = age; + } + + public static Person createToddler() { + return new Person("A toddler", 2); + } + + public static Person createPreschooler() { + return new Person("A preschooler", 5); + } + + public static Person createAdolescent() { + return new Person("An adolescent", 9); + } + + public static Person createTeenager() { + return new Person("A teenager", 15); + } +} diff --git a/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_6/PersonTest.java b/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_6/PersonTest.java new file mode 100644 index 0000000..a7614aa --- /dev/null +++ b/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_6/PersonTest.java @@ -0,0 +1,58 @@ +package me.alex4386.gachon.sw14462.day11.ex6_6; + +public class PersonTest { + public static void main(String[] args) { + Person alex = new Person("Alex", 20); + System.out.println("Person alex = new Person(\"Alex\", 20);"); + + System.out.println("alex.getName() = " + alex.getName()); + System.out.println("alex.getAge() = " + alex.getAge()); + System.out.println("alex.setAge(21)"); + alex.setAge(21); + System.out.println("alex.getAge() = " + alex.getAge()); + + System.out.println("alex.setName(\"Alexey Pajitnov\")"); + alex.setName("Alexey Pajitnov"); + + System.out.println("alex.getName() = " + alex.getName()); + System.out.println("alex.setName(\"Alexander\")"); + alex.setName("Alexander"); + System.out.println("alex.getName() = " + alex.getName()); + + System.out.println("alex.setName(\"Alexey\", \"Pajitnov\")"); + alex.setName("Alexey", "Pajitnov"); + System.out.println("alex.getName() = " + alex.getName()); + + System.out.println("alex.setPerson(\"Alex\", 42)"); + alex.setPerson("Alex", 42); + System.out.println("alex.getName() = " + alex.getName()); + System.out.println("alex.getAge() = " + alex.getAge()); + + Person toddler = Person.createToddler(); + System.out.println("Person toddler = Person.createToddler();"); + System.out.println("toddler.getName() = " + toddler.getName()); + System.out.println("toddler.getAge() = " + toddler.getAge()); + + Person adult = Person.createAdult(); + System.out.println("Person adult = Person.createAdult();"); + System.out.println("adult.getName() = " + adult.getName()); + System.out.println("adult.getAge() = " + adult.getAge()); + + Person preSchooler = Person.createPreschooler(); + System.out.println("Person preSchooler = Person.createPreschooler();"); + System.out.println("preSchooler.getName() = " + preSchooler.getName()); + System.out.println("preSchooler.getAge() = " + preSchooler.getAge()); + + Person teenager = Person.createTeenager(); + System.out.println("Person teenager = Person.createTeenager();"); + System.out.println("teenager.getName() = " + teenager.getName()); + System.out.println("teenager.getAge() = " + teenager.getAge()); + + Person adolescent = Person.createAdolescent(); + System.out.println("Person adolescent = Person.createAdolescent();"); + System.out.println("adolescent.getName() = " + adolescent.getName()); + System.out.println("adolescent.getAge() = " + adolescent.getAge()); + + System.out.println("End of test."); + } +} diff --git a/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_7/Main.java b/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_7/Main.java new file mode 100644 index 0000000..f74c42b --- /dev/null +++ b/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_7/Main.java @@ -0,0 +1,7 @@ +package me.alex4386.gachon.sw14462.day11.ex6_7; + +public class Main { + public static void main(String[] args) { + TemperatureTest.main(args); + } +} diff --git a/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_7/Temperature.java b/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_7/Temperature.java new file mode 100644 index 0000000..4f0be81 --- /dev/null +++ b/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_7/Temperature.java @@ -0,0 +1,76 @@ +package me.alex4386.gachon.sw14462.day11.ex6_7; + +public class Temperature { + private char unit; + private float value; + + public Temperature(char unit, float value) { + if (unit != 'C' && unit != 'F') { + throw new IllegalArgumentException("Invalid unit (neither celsius or fahrenheit)"); + } + + this.unit = unit; + this.value = value; + } + + public Temperature(float value) { + this('C', value); + } + + public Temperature(char unit) { + this(unit, 0); + } + + public Temperature() { + this('C'); + } + + public float getFahrenheit() { + if (this.unit == 'C') { + return this.value * 9 / 5 + 32; + } else { + return this.value; + } + } + + public float getCelsius() { + if (this.unit == 'F') { + return (this.value - 32) * 5 / 9; + } else { + return this.value; + } + } + + public void setDegree(float value) { + this.value = value; + } + + public void setUnit(char unit) { + this.unit = unit; + } + + public void setTemperature(char unit, float value) { + this.unit = unit; + this.value = value; + } + + public int compareTo(Temperature other) { + if (this.unit == 'C') { + return Float.compare(this.getCelsius(), other.getCelsius()); + } else { + return Float.compare(this.getFahrenheit(), other.getFahrenheit()); + } + } + + public boolean equals(Temperature other) { + return this.compareTo(other) == 0; + } + + public boolean isHotter(Temperature other) { + return this.compareTo(other) > 0; + } + + public boolean isCooler(Temperature other) { + return this.compareTo(other) < 0; + } +} diff --git a/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_7/TemperatureTest.java b/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_7/TemperatureTest.java new file mode 100644 index 0000000..18bf991 --- /dev/null +++ b/src/main/java/me/alex4386/gachon/sw14462/day11/ex6_7/TemperatureTest.java @@ -0,0 +1,53 @@ +package me.alex4386.gachon.sw14462.day11.ex6_7; + +public class TemperatureTest { + public static void main(String[] args) { + Temperature temp0C = new Temperature(); + Temperature temp32F = new Temperature('F', 32); + System.out.println("Temperature temp0C = new Temperature()"); + System.out.println("Temperature temp32F = new Temperature('F', 32)"); + + Temperature tempNeg40C = new Temperature( -40); + Temperature tempNeg40F = new Temperature('F', -40); + System.out.println("Temperature tempNeg40C = new Temperature(-40)"); + System.out.println("Temperature tempNeg40F = new Temperature('F', -40)"); + + Temperature temp100C = new Temperature('C', 100); + Temperature temp212F = new Temperature('F', 212); + System.out.println("Temperature temp100C = new Temperature('C', 100)"); + System.out.println("Temperature temp212F = new Temperature('F', 212)"); + + System.out.println("temp0C.equals(temp32F) = "+temp0C.equals(temp32F)); + System.out.println("temp0C.equals(tempNeg40C) = "+temp0C.equals(tempNeg40F)); + + Temperature testTemp = new Temperature('C', 100); + System.out.println("Temperature testTemp = new Temperature('C', 100)"); + + System.out.println("testTemp.getCelsius() = " + testTemp.getCelsius()); + System.out.println("testTemp.getFahrenheit() = "+testTemp.getFahrenheit()); + System.out.println("testTemp.setUnit('F')"); + testTemp.setUnit('F'); + System.out.println("testTemp.getCelsius() = " + testTemp.getCelsius()); + System.out.println("testTemp.getFahrenheit() = "+testTemp.getFahrenheit()); + System.out.println("testTemp.setDegree(212)"); + testTemp.setDegree(212); + System.out.println("testTemp.getCelsius() = " + testTemp.getCelsius()); + System.out.println("testTemp.getFahrenheit() = "+testTemp.getFahrenheit()); + + System.out.println("testTemp.setTemperature('C', -100)"); + testTemp.setTemperature('C', -100); + System.out.println("testTemp.getCelsius() = " + testTemp.getCelsius()); + System.out.println("testTemp.getFahrenheit() = "+testTemp.getFahrenheit()); + + System.out.println("testTemp.compareTo(temp100C) = "+testTemp.compareTo(temp100C)); + System.out.println("temp100C.compareTo(testTemp) = "+temp100C.compareTo(testTemp)); + + System.out.println("temp100C.isHotter(testTemp) = "+temp100C.isHotter(testTemp)); + System.out.println("testTemp.isHotter(temp100C) = "+testTemp.isHotter(temp100C)); + + System.out.println("tempNeg40C.isCooler(temp212F) = "+tempNeg40C.isCooler(temp212F)); + System.out.println("temp0C.isCooler(testTemp) = "+temp0C.isCooler(testTemp)); + + System.out.println("End of Test"); + } +}