CS145 – PROGRAMMING ASSIGNMENT
CARD HEAP GUI
MORE WITH CARDS
This program focuses on heaps and using the GUI.
Turn in Card.java, CardHeap.java and your main file. You are allowed to reuse your
Card.java from a prior assignment with any necessary changes that you want to add.
You will reuse your Card.java file and you will write the GUI form and the
CardHeap.java files to implement the necessary behavior.
In this assignment, you will implement a simple GUI program that will randomly
add/remove cards that are the same as the ones we used in assignment #7 to a heap.
(Note that we will be ignoring the premium cards, although they should still work.).
Your program should look like the following at the beginning:
After a few adds:
After a few rounds of adding and removal:
After a clear:
THE MAIN PROGRAM
The GUI/main program should do the following:
The add button should create a random card(default constructor) and then add it
to the heap.
Pop should remove the smallest card from the heap.
o It should then print the removed card in the label marked Last Removed
Clear should set the heap to empty.
Every time you press a button it should reset the top label to the toString()
representation of the storage heap. In other words keep the labels updated.
When the program starts, the 2nd label can be blank if you want.
The only significant change that you should do to the Card class is that you should modify the
toString() method to print off the power, toughness, and the cost if you haven’t done so already.
So Instead of [57/732] it should print off [57/732:28] instead.
The heap should be a stored in an Array of Cards. I would not suggest trying to make a generic
heap. You can use the PowerPoint/book as a guide on how to write it.
The methods you will need are:
void add(Card x)
private void expand()
o Only print the used part of the array, do not print the entire storage array.
本网站支持淘宝 支付宝 微信支付 paypal等等交易。如果不放心可以用淘宝交易！
E-mail: [email protected] 微信:itcsdx