CS1 Course Site

CS1 at Oswego

Hypertexknowlogy

Frequently Asked Questions

 
CS1 Course Site  
 
 
Programming Challenge Archive

Incremental Programming
Version 1
 
 
  JavaApplication  -- Card Thing

   // General Information
   // ---------------------------------------------------
  
   // File:  CardThing.java
   // Type:  java application file
   // Date:  Fri Nov 10, 2000
   // Name:  James W. Bremenour
   // Line:  Reads 50 pairs of cards and prints them.
  
   // Application Description
   // ---------------------------------------------------
  
   /*
      The first in a six part series, this program is the
      essential function to the entire program (which 
      will be the result of the sixth version). This 
      version simply reads 50 pairs of cards from the 
      standard input file and displays them per pair.
   */
  
   // Required Packages
   // ---------------------------------------------------
  
      import blue.io.*;
      import blue.cards.*;
  
   // Application Class
   // ---------------------------------------------------
  
      class CardThing
      {
         static public void main (String args[])
         {
         // Create the cards
            Card c;
            Card d;
         // Create a loop that will read, and display
         // each pair.
    for (int i = 1;i < 50;i++)
    {
        String cRank = IO.readString();
        String cSuit = IO.readString();
        c = new Card(cRank, cSuit);
        String dRank = IO.readString();
        String dSuit = IO.readString();
        d = new Card(dRank, dSuit);
        c.print();
        d.print();
        IO.println();
    }
         }
      }
  
   // Demo
   // ---------------------------------------------------
  
   /*
   $ java CardThing < ../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)
   $ 
   */