From bb03704ed8b368fb487b8590f5cd843b2224ff91 Mon Sep 17 00:00:00 2001 From: "Lisa J. Miller" Date: Wed, 20 Aug 2025 17:41:40 -1000 Subject: [PATCH] Add old files to new branch --- src/main/java/ICSatKCC/Bill.java | 37 +++++ src/main/java/ICSatKCC/Coin.java | 180 ++++++++++++--------- src/main/java/ICSatKCC/CoinDriver.java | 59 ------- src/main/java/ICSatKCC/CoinFlipper.java | 78 +++++++++ src/main/java/ICSatKCC/Dime.java | 19 ++- src/main/java/ICSatKCC/DollarCoin.java | 30 ++-- src/main/java/ICSatKCC/Five.java | 15 ++ src/main/java/ICSatKCC/Flippable.java | 31 ++++ src/main/java/ICSatKCC/HalfDollar.java | 19 +-- src/main/java/ICSatKCC/Money.java | 25 +++ src/main/java/ICSatKCC/Nickel.java | 19 +-- src/main/java/ICSatKCC/One.java | 15 ++ src/main/java/ICSatKCC/Penny.java | 29 ++-- src/main/java/ICSatKCC/Quarter.java | 44 ++--- 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 ----------- 21 files changed, 366 insertions(+), 714 deletions(-) create mode 100644 src/main/java/ICSatKCC/Bill.java 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/Five.java create mode 100644 src/main/java/ICSatKCC/Flippable.java create mode 100644 src/main/java/ICSatKCC/Money.java create mode 100644 src/main/java/ICSatKCC/One.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/Bill.java b/src/main/java/ICSatKCC/Bill.java new file mode 100644 index 0000000..2a6d5be --- /dev/null +++ b/src/main/java/ICSatKCC/Bill.java @@ -0,0 +1,37 @@ +package ICSatKCC; +/** +* Money Bill abstract super class. +* @author Lisa Miller +* @since 9/9/2017 +*/ + +public abstract class Bill extends Money{ + protected int serialNum; + + /** + * Two parameter constructor + * CANNOT BE INSTANTIATED BY ITSELF + * @param v the bill value + * @param n the bill type name + */ + public Bill (double v, String n, int s) { + this.value = v; + this.name = n; + this.serialNum = s; + this.color = "green"; + } + + public int getSerialNum(){ + return this.serialNum; + + } + + public String getColor(){ + return this.color; + } + + public String getName(){ + return this.name + "dollar bill"; + + } +} \ No newline at end of file diff --git a/src/main/java/ICSatKCC/Coin.java b/src/main/java/ICSatKCC/Coin.java index f116d73..5b7ccbc 100644 --- a/src/main/java/ICSatKCC/Coin.java +++ b/src/main/java/ICSatKCC/Coin.java @@ -1,82 +1,112 @@ package ICSatKCC; - +import java.util.Random; /** -* Basic Coin super class. +* Flippable Money Coin abstract super class. * @author Lisa Miller -* @since 1/24/22 +* @since 9/9/2017 */ -public class Coin { - //instance variables - /** the Coin value. */ - private double value; - /** the name of the Coin type. */ - private String name; - /** the image on the front of the Coin. */ - private String front; - /** the image on the back. */ - private String back; - - /** - * Two parameter constructor. - * @param newValue the coin value - * @param newName the coin type name - */ - public Coin(double newValue, String newName, String newFront, String newBack) { - this.value = newValue; - this.name = newName; - this.front = newFront; - this.back = newBack; - } +public abstract class Coin extends Money implements Flippable, Comparable{ + //instance variables +// private int date; +// private String shape; +// //added for flippable + private int upSide; + private int downSide; + + /** + * Two parameter constructor + * CANNOT BE INSTANTIATED BY ITSELF + * @param v the coin value + * @param n the coin type name + */ + public Coin (double v, String n, String c) { + this.value = v; + this.name = n; + this.color = c; + this.toss(); //randomly set upside/downSide + } + + //abstract method - not implemented here + public abstract String getBack(); + +/*********** Rest is the same ******************/ + //get methods get Value in Money now +// public double getValue() { +// return this.value; +// } + public String getName() { + return this.name; + } + + //getColor method returns "Silver" + //by default + public String getColor() { + return this.color; + } + - //get methods - /** - * Gets the value of this Coin. - * @return the value of the Coin. - */ - public double getValue() { - return this.value; - } - - /** - * Gets the name of this Coin. - * @return the name of the Coin. - */ - public String getName() { - return this.name; - } - - /** - * Gets the color of this Coin. - * Always returns Silver as the default color. - * @return the color of the Coin, Silver. - */ - public String getColor() { - return "Silver"; - } - - /** - * Gets the description of the front image. - * @return the front of the Coin. - */ - public String getFront() { - return this.front; - } - - /** - * Gets the description of the back image. - * @return the back of the Coin. - */ - public String getBack() { - return this.back; - } - - /** - * Sets the description of the back image. - * @param the back of the Coin. - */ - public void setBack(String newBack) { - this.back = newBack; - } + /** + * Switches value of upSide and downSide. + */ + @Override + public void flip() { + if (upSide == 0) { + upSide = 1; + downSide = 0; + } else { + upSide = 0; + downSide = 1; + } + } + + /** + * Randomly sets upSide and corresponding downSide + */ + @Override + public void toss() { + Random r = new Random(); + upSide = r.nextInt(2); + if (upSide == 0){ + downSide = 1; + } else { + downSide = 0; + } + } + + /** + * Returns the upSide + * @return the up facing side + */ + @Override + public int getUpSide () { + return upSide; + } + + /** + * Sets the upSide + * @param i the new up facing side + */ + @Override + public void setUpSide (int i) { + upSide = i; + } + + //to string method + public String toString(){ + return this.value + " cents"; + } -} + //compareTo method + public int compareTo(Coin c){ + double diff; + int iDiff; + //have to call getValue for c because don't have access + diff = this.value - c.getValue(); + + iDiff = (int)(diff*100);//return integer difference in cents + + return iDiff; + + } +} \ No newline at end of file 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..611c7a1 --- /dev/null +++ b/src/main/java/ICSatKCC/CoinFlipper.java @@ -0,0 +1,78 @@ +package ICSatKCC; + +/** +* Driver class for Flippable Coins. +* @author Lisa Miller +* @since 1/28/24 +*/ + +public class CoinFlipper { + /** main method. + * @param args not used + */ + public static void main( String [] args){ + + //array of coins can hold all subclasses + Coin[] coinArr = new Coin[3]; + + coinArr[0] = new DollarCoin(); + coinArr[1] = new Penny(); + coinArr[2] = (Coin)doubleFlip(coinArr[0]); //call doubleFlip + + 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())); + } + + for(int i = 0; i < coinArr.length; i++) { + System.out.println(coinArr[i]); + } + + + + }//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 == 1){ + 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(); + Flippable c = new Quarter(); + + switch(side){ + case 0: + c = new Penny(); + break; + case 1: + c = new Nickel(); + 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..0b9b2c5 100644 --- a/src/main/java/ICSatKCC/Dime.java +++ b/src/main/java/ICSatKCC/Dime.java @@ -1,17 +1,16 @@ 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", "silver"); + } + //required by Coin abstract class + public String getBack(){ + return "torch"; + } } diff --git a/src/main/java/ICSatKCC/DollarCoin.java b/src/main/java/ICSatKCC/DollarCoin.java index 5d66d46..a6fbf91 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", "gold"); + } + + //required by Coin abstract class + public String getBack(){ + return "eagle"; + } } diff --git a/src/main/java/ICSatKCC/Five.java b/src/main/java/ICSatKCC/Five.java new file mode 100644 index 0000000..9d31bf6 --- /dev/null +++ b/src/main/java/ICSatKCC/Five.java @@ -0,0 +1,15 @@ +package ICSatKCC; +/** +* Five dollar Bill Subclass +* @author Lisa Miller +* @since 9/9/2017 +*/ +public class Five extends Bill { + + public Five(){ + super(5.00,"five", 123456); + + } + + +} diff --git a/src/main/java/ICSatKCC/Flippable.java b/src/main/java/ICSatKCC/Flippable.java new file mode 100644 index 0000000..ab30e97 --- /dev/null +++ b/src/main/java/ICSatKCC/Flippable.java @@ -0,0 +1,31 @@ +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..2a5ed9e 100644 --- a/src/main/java/ICSatKCC/HalfDollar.java +++ b/src/main/java/ICSatKCC/HalfDollar.java @@ -1,16 +1,17 @@ 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", "Silver"); + } + + //required by Coin abstract class + public String getBack(){ + return "presidential seal"; + } } diff --git a/src/main/java/ICSatKCC/Money.java b/src/main/java/ICSatKCC/Money.java new file mode 100644 index 0000000..97054ea --- /dev/null +++ b/src/main/java/ICSatKCC/Money.java @@ -0,0 +1,25 @@ +package ICSatKCC; + +/** +* Abstract class for objects that have money properties. +* @author Lisa Miller +* @since 9/7/2017 +*/ + +public abstract class Money { + + //abstract class can have instance variables/data fields + protected double value; + protected String name; + protected String color; + //methods can be defined or abstract + //get methods + public double getValue() { + return this.value; + } + //these have to be implemented by subclasses + public abstract String getName(); + public abstract String getColor(); + + +} \ No newline at end of file diff --git a/src/main/java/ICSatKCC/Nickel.java b/src/main/java/ICSatKCC/Nickel.java index 898155c..9f7d300 100644 --- a/src/main/java/ICSatKCC/Nickel.java +++ b/src/main/java/ICSatKCC/Nickel.java @@ -1,16 +1,17 @@ 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", "Silver"); + } + //required by Coin abstract class + public String getBack(){ + return "Monticello"; + } } diff --git a/src/main/java/ICSatKCC/One.java b/src/main/java/ICSatKCC/One.java new file mode 100644 index 0000000..325b6a6 --- /dev/null +++ b/src/main/java/ICSatKCC/One.java @@ -0,0 +1,15 @@ +package ICSatKCC; +/** +* One dollar Bill Subclass +* @author Lisa Miller +* @since 9/9/2017 +*/ +public class One extends Bill { + + public One(){ + super(1.00,"one", 123456); + + } + + +} diff --git a/src/main/java/ICSatKCC/Penny.java b/src/main/java/ICSatKCC/Penny.java index 57b05d4..24f73a0 100644 --- a/src/main/java/ICSatKCC/Penny.java +++ b/src/main/java/ICSatKCC/Penny.java @@ -1,27 +1,18 @@ 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"); - } - + public Penny(){ + super(.01,"penny", "copper"); + } + + //required by Coin abstract class + public String getBack(){ + return "shield"; + } - /** - * Gets the color of a Penny. - * Overrides superclass getColor method - * @return the color of a Penny Coin. - */ - @Override - public String getColor() { - return "Copper"; - } } diff --git a/src/main/java/ICSatKCC/Quarter.java b/src/main/java/ICSatKCC/Quarter.java index aefe270..d30b9f4 100644 --- a/src/main/java/ICSatKCC/Quarter.java +++ b/src/main/java/ICSatKCC/Quarter.java @@ -1,41 +1,17 @@ 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", "Silver"); + } + + //required by Coin abstract class + public String getBack(){ + return "eagle"; + } } 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"); - - } - - -}