Goal: Create a currency converter with a user interface similar to the following.
You can use the GridLayout layout manager instead of FlowLayout
for better placement of the controls.
Look up the current exchange rates in the newspaper and hardcode
them into your program. When the Submit button is clicked,
do the following. Take the currency
value in the textbox with its radio button checked
and write the corresponding converted concurrency values into the
other textboxes.
 
Goal:   Create a command line application that
shuffles a deck of cards and deals it into hands of
specified sizes. There are four classes: Card, Stack, Deck,
and Hand. Here is a diagram showing the relationships
between the classes. A dotted arrow indicates an "is used by"
relationship; a solid line indicates an "inherits" relationship.
Unfortunately, the dotted arrows are pointing in the wrong direction
for a "uses" relationship. I don't know if I will get these reversed
before you finish the project.
Instance variables
Instance variables
Here is the way I would write the code to push all 52 cards onto the
inherited stack of the Deck object:
String ranks = "23456789TJQKA", suits = "CDHS";
for(s = 0; s <= 3; s++)
An alternative is this shorter code:
One fairly straightforward (even if relatively slow) is to use a triple for loop
and use the suits and ranks strings discussed in the Deck constructor:
for(i = 0; i < 4; i++)
   
Deck deck = new Deck();
   
for(i = 1; i <= TIMES_TO_SHUFFLE; i++)
   
for(i = 1; i <= CARDS_PER_HAND; i++)
   
west.displayUnsorted();
   
west.displaySorted();
Part B: Dealer   150 Points
Class Card
Instance variables
Takes on the values
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'T' (10),
'J' (Jack),
'Q' (Queen),
'K' (King),
'A' (Ace).
Takes on the values
'C' (club),
'D' (diamond),
'H' (heart),
'S' (spade).Constructor
Sets the suit and rank of the card. Once a card is created,
its instance variables cannot be changed.Methods
 
Return the rank of the card.
Return the suit of the card.
Print the rank and suit of the card. For example,
the 7 of spades would be printed as 7S. The
10 of diamonds should be printed as 10D, not as TD.Class Stack
Uses Card.
An array of cards. Make this array protected so that the Hand
object can get at the array elements for the displaySorted method.
The size of the array specified in the constructor.
If you don't want to introduce a getSize method for the stack,
make this size variable protected instead so the Deck and Hand
objects can access the size of their inherited stack.
The index of the top card in the array.Constructor
Creates a stack with the specified size.Methods
Push a card onto the stack if there is room. Return true if the
push was successful, false otherwise.
Pop a card from the stack if the stack is not empty.
Return true if a card was popped, false otherwise.
Return the Card on top of the stack, null is the stack
is empty.
Return true if the stack is empty, false otherwise.
Return true if the number of cards in the stack equals size,
false otherwise.
If you don't like making the size of the Stack protected, use
this method instead.Class Deck
Inherits Stack.   Uses Card, Stack.
The two supplimentary stacks to use when shuffling the deck.Constructor
Create the inherited stack of size 52 calling the Stack
constructor using super. Then create
the two supplimentary stacks of size 26 each. Finally, repeatedly
push the standard 52 cards into the array of the inherited stack.
int r, s;
   
for(r = 0; r <= 12; r++)
      
push(new Card(ranks.charAt(r), suits.charAt(s));Methods
Move the cards in the inherited stack to the supplimentary stacks.
Then move the cards back into the inherited stack by randomly
taking cards from the left and right stacks. Here is some code that
you can use to randomly move the cards back into the inherited
stack:
for(int i = 1; i <= 52; i++)
{
   
if (((Math.random() < 0.5) && !leftstack.isEmpty()) || rightstack.isEmpty())
   
{
   
   
stack.push(leftstack.top());
   
   
leftstack.pop());
   
else
   
{
   
   
stack.push(rightstack.top());
   
   
rightstack.pop());
   
}
}
Perform the following code:
Card c;
c = top();
pop();
aHand.push(c);
This deals a card from the deck into the hand aHand.
aHand.push(top());
pop();
aHand.push(c);Class Hand
Inherits Stack.   Uses Card.Instance variables
Constructor
Creates a hand of size aSize. You may need to do other thinds,
depending on how you implement displaySorted.Methods
Use a loop to print all the cards in the hand using the
toString method of Card, for example:
3D 8D QS KS 5C 9D 10S AH 2D JS AC 6H QH
(Program this method after you are done with everything else.)
Display the cards in the hand sorted by suits as follows:
S: K Q J 10
H: A Q 6
D: 9 8 3 2
C: A 5
You decide how you want to do this.
    for(j = 0; j < 4; j++)
       for(k = 0; k < hand.getSize(): k++)
       {
         
Check if the kth card in the hand matches
         
the card with suit suits.charAt(i) and
         
ranks.charAt(j). If it matches, print the card.
       }Sample Main Method.
The following code deals out four 13 card bridge hands
and prints them. Test your classes with it.
public static void main(String[] args)
{
   
final int TIMES_TO_SHUFFLE = 5;
   
final int CARDS_PER_HAND = 13;
   
int i;
   
Hand north = new Hand(13);
   
Hand east = new Hand(13);
   
Hand south = new Hand(13);
   
Hand west = new Hand(13);
      
deck.shuffle();
   
{
      
deck.deal(west);
      
deck.deal(north);
      
deck.deal(east);
      
deck.deal(south);
   
}
   
north.displayUnsorted();
   
east.displayUnsorted();
   
south.displayUnsorted();
   
north.displaySorted();
   
east.displaySorted();
   
south.displaySorted();
}