File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,11 +15,13 @@ public class CardTable extends Canvas {
1515 * Creates a CardTable.
1616 * cardset is the name of the folder that contains the card images.
1717 */
18- public CardTable (String cardset ) {
18+ public CardTable () {
1919 setBackground (new Color (0x088A4B ));
2020
2121 // create a 2-D array of card images
2222 images = new Image [14 ][4 ];
23+
24+ String cardset = "cardset-oxymoron" ;
2325 String suits = "cdhs" ;
2426
2527 for (int suit = 0 ; suit <= 3 ; suit ++) {
@@ -81,8 +83,7 @@ public static void main(String[] args) {
8183 frame .setDefaultCloseOperation (JFrame .EXIT_ON_CLOSE );
8284
8385 // add the CardTable
84- String cardset = "cardset-oxymoron" ;
85- Canvas canvas = new CardTable (cardset );
86+ Canvas canvas = new CardTable ();
8687 frame .getContentPane ().add (canvas );
8788
8889 // show the frame
Original file line number Diff line number Diff line change @@ -62,28 +62,6 @@ public static int binarySearch(Card[] cards, Card target) {
6262 return -1 ;
6363 }
6464
65- /**
66- * Binary search (recursive version).
67- */
68- public static int binarySearch (Card [] cards , Card target ,
69- int low , int high ) {
70- System .out .println (low + ", " + high );
71-
72- if (high < low ) {
73- return -1 ;
74- }
75- int mid = (low + high ) / 2 ; // step 1
76- int comp = cards [mid ].compareTo (target );
77-
78- if (comp == 0 ) { // step 2
79- return mid ;
80- } else if (comp < 0 ) { // step 3
81- return binarySearch (cards , target , mid + 1 , high );
82- } else { // step 4
83- return binarySearch (cards , target , low , mid - 1 );
84- }
85- }
86-
8765 /**
8866 * Demonstrates how to call the search methods.
8967 */
@@ -103,10 +81,6 @@ public static void main(String[] args) {
10381 System .out .println ("Failed binary search" );
10482 System .out .println (binarySearch (cards , fake ));
10583 System .out .println ();
106-
107- System .out .println ("Recursive binary search" );
108- System .out .println (binarySearch (cards , jack , 0 , 51 ));
109- System .out .println ();
11084 }
11185
11286}
You can’t perform that action at this time.
0 commit comments