This is a GUI assignment.
First create a data class (not a main class ) named Coin in a file Coin.java that implements the Comparable<Coin> interface. The class has two private data fields, a double for the value of the coin and a String for the name of the coin. There should be on constructor with two parameters a double and a String. These parameters are used to initialize the data fields. There should be two accessors, one for the value and one for the name. Finally provide the toString method which should return the name of the coin in all upper case and implement the compareTo method according to the value of the coin. Test your class first with TestCoinClass.java and then with CoinsArrayListExercise.java. You will need the data file coinData.txt for CoinsArrayListExercise.
Next you are to write a data class (not a main class) named CoinButton. This class should extend the JButton class. See GenericExtendedButton.java from the examples page. The constructor for the class must have one Coin parameter. It should have fields for a Coin, a static ArrayList<Coin>, an int (number of clicks for this coin), a static double (total value of all coins in the purse), a JLabel to display the number of clicks and a static JLabel to display the total value of all coins. It should construct super with the name of the Coin as the text on the button. Provide accessors for the ArrayList<Coin> ( named getPurse() ) and the two JLabel fields( named getCoinLabel() and getTotalLabel() ). Accessors for static fields must also be static. The button action is that each time the button is clicked that coin is added to the (static)ArrayList<Coin>, the number of times that button was clicked is incremented and the total value of all coins that were clicked is calculated. In addition update the number JLabel using the setText method to show the number of times that button was clicked and the total (static) JLabel to display the total value (in the currency format ) of all coins in the purse. Run your program with the main class TestButtonCoins. I will show how the output should look in class on June 2nd.
The assignment is due on Thursday June 8th at the beginning of class. There will be a quiz on the assignment at the beginning of class.