From 5056d4fbf3a17ea67b7a942b26aa16b50ce1ceea Mon Sep 17 00:00:00 2001 From: "Lisa J. Miller" Date: Wed, 20 Aug 2025 17:55:24 -1000 Subject: [PATCH] Added old files for interface branch --- src/main/java/ICSatKCC/Coin.java | 83 ++++++++++++------- src/main/java/ICSatKCC/CoinDriver.java | 59 -------------- src/main/java/ICSatKCC/CoinFlipper.java | 75 +++++++++++++++++ src/main/java/ICSatKCC/Dime.java | 14 ++-- src/main/java/ICSatKCC/DollarCoin.java | 28 +++---- src/main/java/ICSatKCC/Flippable.java | 32 ++++++++ src/main/java/ICSatKCC/HalfDollar.java | 15 ++-- src/main/java/ICSatKCC/Money.java | 0 src/main/java/ICSatKCC/Nickel.java | 15 ++-- src/main/java/ICSatKCC/Penny.java | 30 +++---- src/main/java/ICSatKCC/Quarter.java | 40 ++------- src/test/java/ICSatKCC/AppTest.java | 17 ---- src/test/java/ICSatKCC/DimeTest.java | 76 ----------------- src/test/java/ICSatKCC/DollarCoinTest.java | 73 ----------------- src/test/java/ICSatKCC/HalfDollarTest.java | 73 ----------------- src/test/java/ICSatKCC/NickelTest.java | 74 ----------------- src/test/java/ICSatKCC/PennyTest.java | 73 ----------------- src/test/java/ICSatKCC/QuarterTest.java | 94 ---------------------- 18 files changed, 204 insertions(+), 667 deletions(-) delete mode 100644 src/main/java/ICSatKCC/CoinDriver.java create mode 100644 src/main/java/ICSatKCC/CoinFlipper.java create mode 100644 src/main/java/ICSatKCC/Flippable.java create mode 100644 src/main/java/ICSatKCC/Money.java delete mode 100644 src/test/java/ICSatKCC/AppTest.java delete mode 100644 src/test/java/ICSatKCC/DimeTest.java delete mode 100644 src/test/java/ICSatKCC/DollarCoinTest.java delete mode 100644 src/test/java/ICSatKCC/HalfDollarTest.java delete mode 100644 src/test/java/ICSatKCC/NickelTest.java delete mode 100644 src/test/java/ICSatKCC/PennyTest.java delete mode 100644 src/test/java/ICSatKCC/QuarterTest.java diff --git a/src/main/java/ICSatKCC/Coin.java b/src/main/java/ICSatKCC/Coin.java index f116d73..c24f64e 100644 --- a/src/main/java/ICSatKCC/Coin.java +++ b/src/main/java/ICSatKCC/Coin.java @@ -1,46 +1,48 @@ package ICSatKCC; +import java.util.Random; /** -* Basic Coin super class. +* Flippable Coin super class. * @author Lisa Miller -* @since 1/24/22 +* @since 9/9/2017 */ -public class Coin { +public class Coin implements Flippable { //instance variables /** the Coin value. */ private double value; - /** the name of the Coin type. */ + /** The Coin name. */ private String name; - /** the image on the front of the Coin. */ - private String front; - /** the image on the back. */ - private String back; + /** The coin color. */ + private String color; + //added for flippable + /** The Coin side facing up. */ + private int upSide; + /** The Coin side facing down. */ + private int downSide; /** * Two parameter constructor. * @param newValue the coin value * @param newName the coin type name */ - public Coin(double newValue, String newName, String newFront, String newBack) { + public Coin(double newValue, String newName) { this.value = newValue; this.name = newName; - this.front = newFront; - this.back = newBack; + this.toss(); //randomly set upside/downSide } //get methods /** * Gets the value of this Coin. - * @return the value of the Coin. + * @return the value */ public double getValue() { return this.value; } - /** * Gets the name of this Coin. - * @return the name of the Coin. + * @return the name */ public String getName() { return this.name; @@ -48,35 +50,58 @@ public String getName() { /** * Gets the color of this Coin. - * Always returns Silver as the default color. - * @return the color of the Coin, Silver. + * @return "Silver by default */ public String getColor() { return "Silver"; } + + /** + * Switches value of upSide and downSide. + */ + @Override + public void flip() { + if (upSide == 0) { + upSide = 1; + downSide = 0; + } + else { + upSide = 0; + downSide = 1; + } + } + /** - * Gets the description of the front image. - * @return the front of the Coin. + * Randomly sets upSide and corresponding downSide. */ - public String getFront() { - return this.front; + @Override + public void toss() { + Random r = new Random(); + upSide = r.nextInt(2); + if (upSide == 0) { + downSide = 1; + } + else { + downSide = 0; + } } /** - * Gets the description of the back image. - * @return the back of the Coin. + * Returns the upSide. + * @return the up facing side */ - public String getBack() { - return this.back; + @Override + public int getUpSide() { + return upSide; } /** - * Sets the description of the back image. - * @param the back of the Coin. + * Sets the upSide. + * @param i the new up facing side */ - public void setBack(String newBack) { - this.back = newBack; + @Override + public void setUpSide(int i) { + upSide = i; } - } diff --git a/src/main/java/ICSatKCC/CoinDriver.java b/src/main/java/ICSatKCC/CoinDriver.java deleted file mode 100644 index 8d9a135..0000000 --- a/src/main/java/ICSatKCC/CoinDriver.java +++ /dev/null @@ -1,59 +0,0 @@ -package ICSatKCC; - -/** -* Driver class for Basic Coins. -* @author Lisa Miller -* @since 1/24/22 -*/ -public class CoinDriver { - - /** main method. - * @param args not used - */ - public static void main(String[] args) { - - //test all the constructors - DollarCoin c1 = new DollarCoin(); - HalfDollar c2 = new HalfDollar(); - Quarter c3 = new Quarter(); - Dime c4 = new Dime(); - Nickel c5 = new Nickel(); - Penny c6 = new Penny(); - - //State Quarters - Quarter s1 = new Quarter("Hawaii"); - Quarter s2 = new Quarter("California"); - - System.out.print("The first coin is a " + c1.getName()); - System.out.print(", it is " + c1.getColor() + " colored,"); - System.out.println(" it is worth $ " + c1.getValue()); - - System.out.print("The second coin is a " + c2.getName()); - System.out.print(", it is " + c2.getColor() + " colored,"); - System.out.println(" it is worth $ " + c2.getValue()); - - System.out.print("The third coin is a " + c3.getName()); - System.out.print(", it is " + c3.getColor() + " colored,"); - System.out.println(" it is worth $ " + c3.getValue()); - - System.out.print("The fourth coin is a " + c4.getName()); - System.out.print(", it is " + c4.getColor() + " colored,"); - System.out.println(" it is worth $ " + c4.getValue()); - - System.out.print("The fifth coin is a " + c5.getName()); - System.out.print(", it is " + c5.getColor() + " colored,"); - System.out.println(" it is worth $ " + c5.getValue()); - - System.out.print("The sixth coin is a " + c6.getName()); - System.out.print(", it is " + c6.getColor() + " colored,"); - System.out.println(" it is worth $ " + c6.getValue()); - - - System.out.println("\n\nThe back of a regular Quarter is: " + c3.getBack()); - System.out.println("The back of a Hawaii Quarter is: " + s1.getBack()); - System.out.println("The back of a California Quarter is: " + s2.getBack()); - - } //close main - - -} //close class diff --git a/src/main/java/ICSatKCC/CoinFlipper.java b/src/main/java/ICSatKCC/CoinFlipper.java new file mode 100644 index 0000000..ce4c9d8 --- /dev/null +++ b/src/main/java/ICSatKCC/CoinFlipper.java @@ -0,0 +1,75 @@ +package ICSatKCC; + +/** +* Driver class for Flippable Coins +* @author Lisa Miller +* @since 9/9/2017 +*/ + +public class CoinFlipper{ + public static void main( String [] args){ + + //array of coins can hold all subclasses + Coin[] coinArr = new Coin[2]; + + coinArr[0] = new Dime(); + coinArr[1] = new Penny(); + + for (int i = 0; i < coinArr.length; i++){ + System.out.print("Coin type: " + coinArr[i].getName() + "\tValue: " + coinArr[i].getValue()); + System.out.println("\tColor: " + coinArr[i].getColor() + "\tUp Side: " + coinArr[i].getUpSide()); + } + + //do ten coin tosses: + for (int i = 0; i < 10; i++) { + System.out.print(printUpSide(coinArr[0].getUpSide()) + " -> "); + coinArr[0].toss(); + System.out.println(printUpSide(coinArr[0].getUpSide())); + } + + Flippable f = doubleFlip(coinArr[0]); + System.out.println("Got back : " + f); + + + }//close main + + /** + * private static method for getting upside as a string + * @param i the upSide int value + * @return the upSide String value + */ + private static String printUpSide(int i) { + if (i == 0){ + return("Heads"); + }else { + return("Tails"); + } + } + + /** + * mathod that takes in a flippable object, makes a new coin based on the side + * and returns it + * @param an object to get side + * @return a new COin object + */ + public static Flippable doubleFlip(Flippable f1){ + f1.flip(); + f1.flip(); + int side = f1.getUpSide(); + Coin c; + + switch(side){ + case 0: + c = new Penny(); + break; + case 1: + c = new Nickel(); + break; + default: + c = new Coin(0.0, "some other coin"); + break; + } + return c; + }//end doubleFlip + +}//close class \ No newline at end of file diff --git a/src/main/java/ICSatKCC/Dime.java b/src/main/java/ICSatKCC/Dime.java index fb70823..fe53094 100644 --- a/src/main/java/ICSatKCC/Dime.java +++ b/src/main/java/ICSatKCC/Dime.java @@ -1,17 +1,13 @@ package ICSatKCC; /** -* Dime .10 value Coin Subclass. +* Dime Coin Subclass * @author Lisa Miller -* @since 1/24/22 +* @since 9/9/2017 */ public class Dime extends Coin { - /** - * Constructor, needs no parameters. - * Sends default Dime values - */ - public Dime() { - super(.10, "Dime", "Franklin D. Roosevelt", "torch"); - } + public Dime(){ + super(.10,"dime"); + } } diff --git a/src/main/java/ICSatKCC/DollarCoin.java b/src/main/java/ICSatKCC/DollarCoin.java index 5d66d46..d8f22b9 100644 --- a/src/main/java/ICSatKCC/DollarCoin.java +++ b/src/main/java/ICSatKCC/DollarCoin.java @@ -1,25 +1,17 @@ package ICSatKCC; /** -* DollarCoin 1.00 value Coin Subclass. +* DollarCoin Coin Subclass * @author Lisa Miller -* @since 1/24/22 +* @since 9/9/2017 */ public class DollarCoin extends Coin { - /** - * Constructor, needs no parameters. - * Sends default Dollar values - */ - public DollarCoin() { - super(1.0, "Dollar", "Sacagawea", "Bald Eagle"); - } - - /** - * Gets the color of a Dollar Coin. - * Overrides superclass getColor method - * @return the color of a DollarCoin Coin. - */ - public String getColor() { - return "Gold"; - } + + public DollarCoin(){ + super(1.0,"dollar"); + } + + public String getColor () { + return "gold"; + } } diff --git a/src/main/java/ICSatKCC/Flippable.java b/src/main/java/ICSatKCC/Flippable.java new file mode 100644 index 0000000..86f43be --- /dev/null +++ b/src/main/java/ICSatKCC/Flippable.java @@ -0,0 +1,32 @@ +package ICSatKCC; + +/** +* Interface for objects that have flippable property. +* @author Lisa Miller +* @since 9/7/2017 +*/ + +public interface Flippable { + + /** + * Swaps caller's up-side + */ + public void flip(); + + /** + * Randomly set caller's up-side + */ + public void toss(); + + /** + * Sets up-side value + * @param i the new up-side value + */ + public void setUpSide(int i); + + /** + * Returns the value of the up-side + * @return the up-side + */ + public int getUpSide(); +} \ No newline at end of file diff --git a/src/main/java/ICSatKCC/HalfDollar.java b/src/main/java/ICSatKCC/HalfDollar.java index 367e3ad..a8581ed 100644 --- a/src/main/java/ICSatKCC/HalfDollar.java +++ b/src/main/java/ICSatKCC/HalfDollar.java @@ -1,16 +1,13 @@ package ICSatKCC; + /** -* HalfDollar .50 value Coin Subclass. +* HalfDollar Coin Subclass * @author Lisa Miller -* @since 1/24/22 +* @since 9/9/2017 */ public class HalfDollar extends Coin { - /** - * Constructor, needs no parameters. - * Sends default HalfDollar values - */ - public HalfDollar() { - super(.50, "Half Dollar", "John F. Kennedy", "Presidential Coat of Arms"); - } + public HalfDollar(){ + super(.50,"halfdollar"); + } } diff --git a/src/main/java/ICSatKCC/Money.java b/src/main/java/ICSatKCC/Money.java new file mode 100644 index 0000000..e69de29 diff --git a/src/main/java/ICSatKCC/Nickel.java b/src/main/java/ICSatKCC/Nickel.java index 898155c..5b057df 100644 --- a/src/main/java/ICSatKCC/Nickel.java +++ b/src/main/java/ICSatKCC/Nickel.java @@ -1,16 +1,13 @@ package ICSatKCC; + /** -* Nickel .05 cent value Coin Subclass. +* Nickel Coin Subclass * @author Lisa Miller -* @since 1/24/22 +* @since 9/9/2017 */ public class Nickel extends Coin { - /** - * Constructor, needs no parameters. - * Sends default Nickel values - */ - public Nickel() { - super(.05, "Nickel", "Thomas Jefferson", "Monticello"); - } + public Nickel(){ + super(.05,"nickel"); + } } diff --git a/src/main/java/ICSatKCC/Penny.java b/src/main/java/ICSatKCC/Penny.java index 57b05d4..bce7946 100644 --- a/src/main/java/ICSatKCC/Penny.java +++ b/src/main/java/ICSatKCC/Penny.java @@ -1,27 +1,17 @@ package ICSatKCC; + /** -* Penny .01 value Coin Subclass. +* Penny Coin Subclass * @author Lisa Miller -* @since 1/24/22 +* @since 9/9/2017 */ public class Penny extends Coin { - /** - * Constructor, needs no parameters. - * Sends default Penny values - */ - public Penny() { - super(.01, "Penny", "Abraham Lincoln", "Lincoln Memorial"); - } - - - /** - * Gets the color of a Penny. - * Overrides superclass getColor method - * @return the color of a Penny Coin. - */ - @Override - public String getColor() { - return "Copper"; - } + public Penny(){ + super(.01,"penny"); + } + + public String getColor () { + return "Copper"; + } } diff --git a/src/main/java/ICSatKCC/Quarter.java b/src/main/java/ICSatKCC/Quarter.java index aefe270..4a41a17 100644 --- a/src/main/java/ICSatKCC/Quarter.java +++ b/src/main/java/ICSatKCC/Quarter.java @@ -1,41 +1,13 @@ package ICSatKCC; + /** -* Quarter .25 value Coin Subclass. +* Quarter Coin Subclass * @author Lisa Miller -* @since 1/24/22 +* @since 9/9/2017 */ public class Quarter extends Coin { - /** - * Constructor, needs no parameters. - * Sends default Quarter values - */ - public Quarter() { - super(.25, "Quarter", "George Washington", "Eagle"); - } - /** - * Constructor, for State Quarters. - * Sets special state backs - */ - public Quarter(String state) { - - super(.25, "Quarter", "George Washington", "Eagle"); - - switch (state) { - case "Hawaii": - super.setBack("Kamehameha"); - break; - case "Nevada": - super.setBack("stallions"); - break; - case "California": - super.setBack("Yosemite"); - break; - default: - //do nothing just leave Eagle - break; - } - } - - + public Quarter(){ + super(.25,"quarter"); + } } diff --git a/src/test/java/ICSatKCC/AppTest.java b/src/test/java/ICSatKCC/AppTest.java deleted file mode 100644 index 3f07710..0000000 --- a/src/test/java/ICSatKCC/AppTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package ICSatKCC; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * Unit test for simple App. - */ -public class AppTest { - - /** - * Rigorous Test :-) - */ - @Test - public void shouldAnswerWithTrue() { - assertTrue(true); - } -} diff --git a/src/test/java/ICSatKCC/DimeTest.java b/src/test/java/ICSatKCC/DimeTest.java deleted file mode 100644 index 3744ff9..0000000 --- a/src/test/java/ICSatKCC/DimeTest.java +++ /dev/null @@ -1,76 +0,0 @@ -package ICSatKCC; - -import static org.junit.Assert.*; -import org.junit.Before; -import org.junit.Test; - -// import junit.framework.Assert; // Removed deprecated import - -/** -* DimeTest - a JUnit test for Dime.java. -* @author Lisa Miller -* @since 1/24/22 -*/ - -public class DimeTest { - - - /** Fixture initialization (common initialization - * for all tests). **/ - @Before public void setUp() { - } - - /** - * Dime getNameTest. - * Checks constructor and getName method - */ - @Test public void getNameTest() { - Dime p = new Dime(); - assertEquals("GetName returns incorrect name.", "Dime", - p.getName()); - - } - - /** - * Dime getValue test. - * Checks constructor and getValue method - */ - @Test public void getValueTest() { - Dime p = new Dime(); - assertEquals("getValue returns incorrect Dime value", .10, p.getValue(), .001); - - } - - /** - * Dime getColor test. - * Checks constructor and getColor method - */ - @Test public void getColorTest() { - Dime p = new Dime(); - assertEquals("getColor returns incorrect Dime color", p.getColor(), "Silver"); - - } - - /** - * Dime getFront test. - * Checks constructor and getFront method - */ - @Test public void getFrontTest() { - Dime p = new Dime(); - assertEquals("getFront returns incorrect Dime front", p.getFront(), "Franklin D. Roosevelt"); - - } - - /** - * Dime getBack test. - * Checks constructor and getFront method - */ - @Test public void getBackTest() { - Dime p = new Dime(); - assertEquals("getBack returns incorrect Dime back", p.getBack(), "torch"); - - } - - - -} diff --git a/src/test/java/ICSatKCC/DollarCoinTest.java b/src/test/java/ICSatKCC/DollarCoinTest.java deleted file mode 100644 index 6a3e498..0000000 --- a/src/test/java/ICSatKCC/DollarCoinTest.java +++ /dev/null @@ -1,73 +0,0 @@ -package ICSatKCC; - -import static org.junit.Assert.*; -import org.junit.Before; -import org.junit.Test; -/** -* DollarCoinTest - a JUnit test for DollarCoin.java. -* @author Lisa Miller -* @since 1/24/22 -*/ - -public class DollarCoinTest { - - - /** Fixture initialization (common initialization - * for all tests). **/ - @Before public void setUp() { - } - - /** - * DollarCoin getNameTest. - * Checks constructor and getName method - */ - @Test public void getNameTest() { - DollarCoin p = new DollarCoin(); - assertEquals("GetName returns incorrect name.", "Dollar", - p.getName()); - - } - - /** - * DollarCoin getValue test. - * Checks constructor and getValue method - */ - @Test public void getValueTest() { - DollarCoin p = new DollarCoin(); - assertEquals("getValue returns incorrect DollarCoin value", 1.0, p.getValue(), .001); - - } - - /** - * DollarCoin getColor test. - * Checks constructor and getColor method - */ - @Test public void getColorTest() { - DollarCoin p = new DollarCoin(); - assertEquals("getColor returns incorrect DollarCoin color", p.getColor(), "Gold"); - - } - - /** - * DollarCoin getFront test. - * Checks constructor and getFront method - */ - @Test public void getFrontTest() { - DollarCoin p = new DollarCoin(); - assertEquals("getFront returns incorrect DollarCoin front", p.getFront(), "Sacagawea"); - - } - - /** - * DollarCoin getBack test. - * Checks constructor and getFront method - */ - @Test public void getBackTest() { - DollarCoin p = new DollarCoin(); - assertEquals("getBack returns incorrect DollarCoin back", p.getBack(), "Bald Eagle"); - - } - - - -} diff --git a/src/test/java/ICSatKCC/HalfDollarTest.java b/src/test/java/ICSatKCC/HalfDollarTest.java deleted file mode 100644 index 9ae74bc..0000000 --- a/src/test/java/ICSatKCC/HalfDollarTest.java +++ /dev/null @@ -1,73 +0,0 @@ -package ICSatKCC; - -import static org.junit.Assert.*; -import org.junit.Before; -import org.junit.Test; -/** -* HalfDollarTest - a JUnit test for HalfDollar.java. -* @author Lisa Miller -* @since 1/24/22 -*/ - -public class HalfDollarTest { - - - /** Fixture initialization (common initialization - * for all tests). **/ - @Before public void setUp() { - } - - /** - * HalfDollar getNameTest. - * Checks constructor and getName method - */ - @Test public void getNameTest() { - HalfDollar p = new HalfDollar(); - assertEquals("GetName returns incorrect name.", "Half Dollar", - p.getName()); - - } - - /** - * HalfDollar getValue test. - * Checks constructor and getValue method - */ - @Test public void getValueTest() { - HalfDollar p = new HalfDollar(); - assertEquals("getValue returns incorrect HalfDollar value", .50, p.getValue(), .001); - - } - - /** - * HalfDollar getColor test. - * Checks constructor and getColor method - */ - @Test public void getColorTest() { - HalfDollar p = new HalfDollar(); - assertEquals("getColor returns incorrect HalfDollar color", p.getColor(), "Silver"); - - } - - /** - * HalfDollar getFront test. - * Checks constructor and getFront method - */ - @Test public void getFrontTest() { - HalfDollar p = new HalfDollar(); - assertEquals("getFront returns incorrect HalfDollar front", p.getFront(), "John F. Kennedy"); - - } - - /** - * HalfDollar getBack test. - * Checks constructor and getFront method - */ - @Test public void getBackTest() { - HalfDollar p = new HalfDollar(); - assertEquals("getBack returns incorrect HalfDollar back", p.getBack(), "Presidential Coat of Arms"); - - } - - - -} diff --git a/src/test/java/ICSatKCC/NickelTest.java b/src/test/java/ICSatKCC/NickelTest.java deleted file mode 100644 index a072f4f..0000000 --- a/src/test/java/ICSatKCC/NickelTest.java +++ /dev/null @@ -1,74 +0,0 @@ -package ICSatKCC; - -import static org.junit.Assert.*; -import org.junit.Before; -import org.junit.Test; - -/** -* NickelTest - a JUnit test for Nickel.java. -* @author Lisa Miller -* @since 1/24/22 -*/ - -public class NickelTest { - - - /** Fixture initialization (common initialization - * for all tests). **/ - @Before public void setUp() { - } - - /** - * Nickel getNameTest. - * Checks constructor and getName method - */ - @Test public void getNameTest() { - Nickel p = new Nickel(); - assertEquals("GetName returns incorrect name.", "Nickel", - p.getName()); - - } - - /** - * Nickel getValue test. - * Checks constructor and getValue method - */ - @Test public void getValueTest() { - Nickel p = new Nickel(); - assertEquals("getValue returns incorrect Nickel value", .05, p.getValue(), .001); - - } - - /** - * Nickel getColor test. - * Checks constructor and getColor method - */ - @Test public void getColorTest() { - Nickel p = new Nickel(); - assertEquals("getColor returns incorrect Nickel color", p.getColor(), "Silver"); - - } - - /** - * Nickel getFront test. - * Checks constructor and getFront method - */ - @Test public void getFrontTest() { - Nickel p = new Nickel(); - assertEquals("getFront returns incorrect Nickel front", p.getFront(), "Thomas Jefferson"); - - } - - /** - * Nickel getBack test. - * Checks constructor and getFront method - */ - @Test public void getBackTest() { - Nickel p = new Nickel(); - assertEquals("getBack returns incorrect Nickel back", p.getBack(), "Monticello"); - - } - - - -} diff --git a/src/test/java/ICSatKCC/PennyTest.java b/src/test/java/ICSatKCC/PennyTest.java deleted file mode 100644 index cf894e7..0000000 --- a/src/test/java/ICSatKCC/PennyTest.java +++ /dev/null @@ -1,73 +0,0 @@ -package ICSatKCC; - -import static org.junit.Assert.*; -import org.junit.Before; -import org.junit.Test; -/** -* PennyTest - a JUnit test for Penny.java. -* @author Lisa Miller -* @since 1/24/22 -*/ - -public class PennyTest { - - - /** Fixture initialization (common initialization - * for all tests). **/ - @Before public void setUp() { - } - - /** - * Penny getNameTest. - * Checks constructor and getName method - */ - @Test public void getNameTest() { - Penny p = new Penny(); - assertEquals("GetName returns incorrect name.", "Penny", - p.getName()); - - } - - /** - * Penny getValue test. - * Checks constructor and getValue method - */ - @Test public void getValueTest() { - Penny p = new Penny(); - assertEquals("getValue returns incorrect Penny value", .01, p.getValue(), .001); - - } - - /** - * Penny getColor test. - * Checks constructor and getColor method - */ - @Test public void getColorTest() { - Penny p = new Penny(); - assertEquals("getColor returns incorrect Penny color", p.getColor(), "Copper"); - - } - - /** - * Penny getFront test. - * Checks constructor and getFront method - */ - @Test public void getFrontTest() { - Penny p = new Penny(); - assertEquals("getFront returns incorrect Penny front", p.getFront(), "Abraham Lincoln"); - - } - - /** - * Penny getBack test. - * Checks constructor and getFront method - */ - @Test public void getBackTest() { - Penny p = new Penny(); - assertEquals("getBack returns incorrect Penny back", p.getBack(), "Lincoln Memorial"); - - } - - - -} diff --git a/src/test/java/ICSatKCC/QuarterTest.java b/src/test/java/ICSatKCC/QuarterTest.java deleted file mode 100644 index f4ef587..0000000 --- a/src/test/java/ICSatKCC/QuarterTest.java +++ /dev/null @@ -1,94 +0,0 @@ -package ICSatKCC; - -import static org.junit.Assert.*; -import org.junit.Before; -import org.junit.Test; - -/** -* QuarterTest - a JUnit test for Quarter.java. -* @author Lisa Miller -* @since 1/24/22 -*/ - -public class QuarterTest { - - - /** Fixture initialization (common initialization - * for all tests). **/ - @Before public void setUp() { - } - - /** - * Quarter getNameTest. - * Checks constructor and getName method - */ - @Test public void getNameTest() { - Quarter p = new Quarter(); - assertEquals("GetName returns incorrect name.", "Quarter", - p.getName()); - - } - - /** - * Quarter getValue test. - * Checks constructor and getValue method - */ - @Test public void getValueTest() { - Quarter p = new Quarter(); - assertEquals("getValue returns incorrect Quarter value", .25, p.getValue(), .001); - - } - - /** - * Quarter getColor test. - * Checks constructor and getColor method - */ - @Test public void getColorTest() { - Quarter p = new Quarter(); - assertEquals("getColor returns incorrect Quarter color", p.getColor(), "Silver"); - - } - - /** - * Quarter getFront test. - * Checks constructor and getFront method - */ - @Test public void getFrontTest() { - Quarter p = new Quarter(); - assertEquals("getFront returns incorrect Quarter front", p.getFront(), "George Washington"); - - } - - /** - * Quarter getBack test. - * Checks constructor and getFront method - */ - @Test public void getBackTest() { - Quarter p = new Quarter(); - assertEquals("getBack returns incorrect Quarter back", p.getBack(), "Eagle"); - - } - - - /** - * Quarter getStateFront test. - * Checks constructor and getFront method - */ - @Test public void getStateFrontTest() { - Quarter p = new Quarter("Hawaii"); - assertEquals("getFront returns incorrect Hawaii Quarter front", p.getFront(), "George Washington"); - - } - - /** - * Quarter getBack test. - * Checks constructor and getFront method - */ - @Test public void getStateBackTest() { - Quarter p = new Quarter("Hawaii"); - assertEquals("getBack returns incorrect Hawaii Quarter back", p.getBack(), "Kamehameha"); - - } - - -}