P Dunn's Super CS1 Site

CS1 at Oswego

Hypertexknowlogy

Frequently Asked Questions

 
P Dunn's Super CS1 Site  
 
 
Programming Challenge Archive

Incremental Programming
version 1 of Card Thing
 
 
  Java Application  -- CardThingApp

   // General Information
   // ---------------------------------------------------
  
   // File:  CardThingApp.java
   // Type:  java application file
   // Date:  Wed Nov  1, 2000
   // Name:  Patrick Dunn
   // Line:  V1 - reads 50 card pair representations
   //        from the input file and displays them
  
   // Application Description
   // ---------------------------------------------------
  
   /*
     This program reads in 50 card pair representations,
     creates a card object for each of them and displays
     what they are by rank and suit on the standard 
     output.
   */
  
   // Required Packages
   // ---------------------------------------------------
  
      import blue.io.*;
      import blue.cards.*;
  
   // Application Class
   // ---------------------------------------------------
  
      class CardThingApp
      {
         static public void main (String args[])
         {
     Card c;  // card 1
     Card d;  // card 2
  
     int counter = 1;  // init counter
     while(counter <= 50)
         {
     // read in the card rank and suit
     String cRank = IO.readString();
     String cSuit = IO.readString();
  
     // create a new card object
     c = new Card(cRank,cSuit);
  
     // read in the card rank and suit
     String dRank = IO.readString();
     String dSuit = IO.readString();
  
     // create a new card object
     d = new Card(dRank,dSuit);
  
     // display the objects
     c.print();
     d.print();
     IO.println();
  
     // increment the counter
     counter++;
  
         }
         }
      }
  
   // Demo
   // ---------------------------------------------------
  
   /*
   [patdunn@k6 v1]$ java CardThingApp < ../CardThing.data 
   (2,S)(K,S)
   (K,D)(K,H)
   (3,C)(4,D)
   (Q,H)(Q,S)
   (7,D)(J,D)
   (2,H)(2,D)
   (7,H)(2,S)
   (9,S)(10,C)
   (J,C)(J,S)
   (Q,S)(6,H)
   (6,H)(7,D)
   (6,C)(6,S)
   (A,D)(2,C)
   (K,C)(J,H)
   (J,S)(10,S)
   (J,S)(10,C)
   (9,D)(9,H)
   (5,S)(J,C)
   (5,H)(6,H)
   (9,D)(4,C)
   (8,C)(8,S)
   (9,D)(10,S)
   (Q,H)(2,H)
   (5,C)(6,C)
   (9,D)(A,H)
   (6,S)(K,H)
   (K,D)(10,H)
   (3,C)(4,S)
   (5,H)(Q,D)
   (J,C)(J,D)
   (2,H)(2,D)
   (7,D)(3,S)
   (9,S)(9,C)
   (J,C)(J,S)
   (7,S)(6,H)
   (6,C)(7,D)
   (7,S)(6,S)
   (A,D)(A,C)
   (K,D)(J,H)
   (J,C)(10,S)
   (J,S)(J,C)
   (9,D)(5,D)
   (5,C)(J,C)
   (5,H)(6,H)
   (9,D)(4,H)
   (8,C)(8,D)
   (9,D)(6,S)
   (Q,H)(2,C)
   (5,S)(6,C)
   (Q,H)(A,H)
   [patdunn@k6 v1]$ 
   */