CPSC 124 Introduction to Programming Spring 2011

CPSC 124 Syllabus

Readings are to be done for the class period where they are listed. Warmups are due by midnight before the class for which they are listed.

Optional readings are more advanced or extra material for those who are curious or want to go beyond the basics - you are encouraged to check them out, but they will not be addressed in class.

Dates for things in light gray are tenative and may shift slightly.

 Assignments

Week 1: 1/19-1/21

Topics: course introduction; the mental landscape; basic building blocks

     

Wed Notes: course introduction      

Fri Reading:

Examples:

  • GasCalc.java (basic program structure, declaring and using variables, output)
warmup #1
(on Blackboard)
due Thu 11:59pm
   

Week 2: 1/24-1/28

Topics: basic building blocks; algorithms

     

Mon Reading:
  • Eck sections 2.3.1-2.3.2, 2.4.1-2.4.3, 2.5.1-2.5.2, 2.5.6-2.5.8 (skip the bits about operators not yet covered in the reading in 2.5.8) [reading guide]
  • optional reading: Eck sections 2.4.4-2.4.5

Examples:

Important: If you already have an account on the math/CS Linux computers, make sure you remember your password and can log in. If not, send an email with your username to Scotty Orr (scottyorr@hws.edu) by Monday and ask for your password to be reset. (If you don't have an account, you don't need to do anything - you'll receive your password in lab on Tuesday.)

warmup #2
(on Blackboard)
due Sun 11:59pm
   

Tue Reading: Eck section 2.6.2 (just to get a sense of the process - the lab will introduce the particular tools and directory setup)   lab #1
Introduction to Linux and Java
due Tue Feb 1
 

Wed In Class: 5-minute syntax quiz on variable declarations, assignment statements, expressions, input, and output. Expect questions of the following types:
  • Declare a variable called length that will hold an integer.
  • Store the value 42 in the variable called size.
  • Read in a line of text as input and store it in a variable called text.
  • Write an expression to add 10 to the result of dividing 8 by 2. (and then possibly print the result or store it in a variable)
  • Print the message Hello world!. (or the value of a variable or expression)

Examples:

   

Fri Reading: Eck sections 2.5.3-2.5.4, 2.5.8, 3.1-3.2 [reading guide]

Examples:

warmup #3
(on Blackboard)
due Thu 11:59pm
 

Week 3: 1/31-2/4

Topics: conditionals and loops

   

Mon Reading:
  • Eck section 3.5 [reading guide]
  • optional reading: Eck section 3.6 (for section 3.6.3, you should read section 2.3.3 first)

Examples:

warmup #4
(on Blackboard)
due Sun 11:59pm
 

Tue     lab #2
First Programs
due Tue Feb 8
 

Wed Reading:
  • Eck sections 3.3.1, 3.3.3, 3.4.1-3.4.2 [reading guide]
  • optional reading: Eck section 3.3.2

In Class: 5-minute syntax quiz on if statements. Expect questions which ask you to translate pseudocode, such as:

  • if x is greater than 10,
      print "big!"
    otherwise
      print "small!"
    
  • if x is between 0 and 100,
      if x is less than or equal to 50 or greater than 75,
        print "A"
    else if x is between 101 and 200,
      print "B"
    

Examples:

warmup #5
(on Blackboard)
due Tue 11:59pm
 

Fri Examples:    

Week 4: 2/7-2/11

Topics: loops; arrays

   

Mon Reading:
  • Eck sections 3.4.3 [reading guide]
  • optional reading: Eck section 3.4.4 (requires reading section 2.3.3 first)

In Class: 5-minute syntax quiz on loops. Expect questions of the form:

  • Write a loop to repeat a task some number of times e.g.
    repeat 10 times
      System.out.println("*");
    
  • Write a loop to repeat a task as long as some condition is true e.g.
    target = 0;
    repeat as long as target does not equal 5
      target = (int)(Math.random()*10);
    

As indicated, you'll be provided with code for everything except the loop syntax itself (which will be expressed in pseudocode). You can write a while loop or a for loop.

Examples:

warmup #6
(on Blackboard)
due Sun 11:59pm
 

Tue     lab #3
Control
due Tue Feb 15
 

Wed Examples:    

Fri Reading:
  • Eck sections 7.1, 7.2.1, 7.2.4 [reading guide]
  • optional reading: Eck section 7.2.2

Examples:

warmup #7
(on Blackboard)
due Thu 11:59pm
 

Week 5: 2/14-2/18

Topics: arrays

   

Mon In Class: 5-minute syntax quiz on arrays. Expect questions of the following types:
  • Declare an array of integers called numbers, and set it up with 10 compartments.
  • Print the number of slots in the array numbers.
  • Store the value 42 in the third slot of the array numbers.
  • Print out (initialize, add 5 to, etc) the values in each slot of the array numbers.

Examples:

   

Tue     lab #4
Arrays
due Tue Feb 22
 

Wed Reading:
  • Eck sections 7.5.1-7.5.2 [reading guide]
  • optional reading: Eck section 7.5.3 (an example of 2D arrays, but uses classes and subroutines, which we haven't covered yet)

Examples:

warmup #8
(on Blackboard)
due Tue 11:59pm
 

Fri Examples:    

Week 6: 2/21-2/25

Topics: subroutines

   

Mon Reading:
  • Eck sections 4.1-4.2.3 [reading guide]
  • optional reading: Eck section 4.2.4 (static member variables are sometimes necessary, but it is often possible - and better - to use parameters and return values instead)

Examples:

warmup #9
(on Blackboard)
due Sun 11:59pm
 

Tue       project #1
Minesweeper
pseudocode due Fri Feb 25
program due Tue Mar 8

Wed
exam #1
Wed 2/23 in class
   

Fri Reading: Eck sections 4.3.1-4.3.4 [reading guide]

Examples:

warmup #10
(on Blackboard)
due Thu 11:59pm
 

Week 7: 2/28-3/4

Topics: subroutines

   

Mon Reading:

In Class: 5-minute syntax quiz on subroutines and subroutines with parameters. Expect questions of the following types:

  • Write the header (body not needed) for a subroutine to print the maximum of two integers: it should take two integers as parameters and print the larger of the two.
  • Write statement(s) to print the larger of 10 and the value stored in the variable x. Use your print maximum subroutine.

Examples:

warmup #11
(on Blackboard)
due Sun 11:59pm
 

Tue     lab #5
Subroutines
due Tue Mar 8

Wed Reading: Eck section 4.4 [reading guide]

Examples:

warmup #12
(on Blackboard)
due Tue 11:59pm

Fri Examples:  

Week 8: 3/7-3/11

Topics: creating programs with subroutines and functions

 

Mon In Class: 5-minute syntax quiz on functions and return statements. Expect questions of the following types:
  • Write a complete definition (header and body) for a function which computes the maximum of two integers: it should take two integers as parameters and return the larger of the two.
  • Write statement(s) to print the larger of 10 and the value stored in the variable x. Use your compute maximum function.

Examples:

 

Tue     lab #6
Functions
due Tue Mar 22
 

Wed Reading: Eck section 4.7 [reading guide]

Examples:

warmup #13
(on Blackboard)
due Tue 11:59pm
 

Fri Reading: no reading for today, but look ahead to 3/21 so you don't have to do the reading over spring break!

Examples:

   

Spring Break


Week 9: 3/21-3/25

Topics: objects and classes

  lab #6
Functions
(continued)
due Tue Mar 22
 

Mon Reading: Eck section 1.5 and the "Objects" handout posted on Blackboard (under "Course Documents") [reading guide]

Examples:

   

Tue Reading: Eck section 5.4 (just pay attention to what methods each class has and to the example in section 5.4.3 - don't worry about how to write or design a class)   lab #7
Using Objects
due Tue Mar 29
 

Wed In Class: 5-minute syntax quiz on using objects. Expect questions of the following type:
  • Write Java statement(s) to create a Deck of cards, shuffle it, deal a card, and print the suit and value of the dealt card.

You may be asked to work with the Card, Deck, and Hand classes, or with a new class. You will be provided with the API of any classes you are to use (including Card, Deck, Hand), similar in format to the Card/Hand/Deck handout.

Examples:

   

Fri Reading: Eck sections 5.1-5.2 [reading guide]

Examples:

warmup #14
(on Blackboard)
due Thu 11:59pm
 

Week 10: 3/28-4/1

Topics: objects and classes

   

Mon Reading: Eck section 5.4.2 [reading guide]

Examples:

   

Tue     lab #8
Writing Classes
due Tue Apr 5
 

Wed In Class: 5-minute syntax quiz on writing classes as a blueprint for objects. Expect questions of the following type:
  • Write a complete class called Dice to represent a single die. Your class should have:
    • an instance variable holding the die's current value
    • an instance variable holding the number of sides
    • a constructor which takes the number of sides as a parameter and initializes the instance variables accordingly (set the current value to -1)
    • a getter which returns the die's current value
    • a getter which returns the number of sides
    • a roll method which rolls the die, updating the current value to a new random value between 1 and the number of sides

Examples:

   

Fri Reading: Eck sections 5.3.4, 5.4.1-5.4.2 [reading guide]

Examples:

warmup #15
(on Blackboard)
due Thu 11:59pm
 

Week 11: 4/4-4/8

Topics: data structures: partially full arrays, dynamic arrays, ArrayList

   

Mon Reading: Eck sections 7.3.1-7.3.2 [reading guide] warmup #16
(on Blackboard)
due Sun 11:59pm
 

Tue       project #2
Not the Usual Breakout
design meeting due Tue Apr 12
program due Wed Apr 20

Wed Reading: Eck sections 4.5.2-4.5.3, 5.3.2, 7.3.3-7.3.4 [reading guide]

Examples:

  • ArrayList API
  • full Java API (try looking up String or Math - click on the tiny "All Classes" link at the top and then look for them)
warmup #17
(on Blackboard)
due Tue 11:59pm
 

Fri
exam #2
Fri 4/8 in class
   

Week 12: 4/11-4/15

Topics: data structures; inheritance

   

Mon In Class: 5-minute syntax quiz on using ArrayList. Expect questions asking you to write statement(s) for tasks like the following:
  • Add the necessary import statement to a program in order to use ArrayList.
  • Declare a variable to hold a reference to an ArrayList of integers.
  • Create a new ArrayList of integers object.
  • Insert the value 4 into an ArrayList at the end or at position 2.
  • Remove the value 4 from the ArrayList, or remove the element at position 2.
  • Retrieve and print the element at position 2.
  • Print out the number of elements in an ArrayList.

A section of the ArrayList API will be provided for you for reference.

Examples:

   

Tue     lab #9
Partially-Full and Dynamic Arrays
due Tue Apr 19

Wed Reading: Eck sections 5.5.1-5.5.3, 5.6 [reading guide]

Examples:

warmup #18
(on Blackboard)
due Tue 11:59pm

Fri Examples:  

Week 13: 4/18-4/22

Topics: inheritance and polymorphism; GUI programming

 

Mon Reading: Eck sections 5.5.4-5.5.5, 5.7.1 [reading guide]

In Class: 5-minute syntax quiz on inheritance. Expect questions of the following types:

  • Write a complete class GraphicalDice which is a subclass of Dice (see the example questions for the 3/30 syntax quiz for a description of Dice). Your class should have:
    • an instance variable holding the die's current value
    • an instance variable holding the number of sides
    • instance variables holding the position where the die is to be drawn
    • a constructor which takes the number of sides and the position of the die as parameters and initializes the instance variables accordingly
    • a constructor which takes the position of the die as a parameter and creates a 6-sided die
    • a getter which returns the die's current value
    • a getter which returns the number of sides
    • a paint method which draws the die's current value
    • a roll method which rolls the die and then paints the die with its new value
    Write only the code needed to achieve this functionality: make use of inheritance to reuse as much code as possible.
  • Write Java statement(s) to create a GraphicalDice object with 10 sides in the position (100,200), roll it, paint it on the screen, and print the current value.

Examples:

warmup #19
(on Blackboard)
due Sun 11:59pm

Tue     lab #10
Rabbit Hunt
due Tue Apr 26

Wed Examples:    

Fri Reading:
  • Eck sections 1.6, 6.1, 6.3, 6.6, 6.7.1 [reading guide]
  • optional reading: the rest of Eck section 6.7

Examples:

More Information on GUIs:

warmup #20
(on Blackboard)
due Thu 11:59pm
 

Week 14: 4/25-4/29

Topics: GUI programming

   

Mon Examples:    

Tue       project #3
Connect Four
due Tue 5/10 10pm

Wed Reading:
  • Eck sections 6.4.1-6.4.4, 6.5.4 [reading guide]
  • optional reading: the rest of Eck section 6.5

Examples:

warmup #21
(on Blackboard)
due Tue 11:59pm
 

Fri Examples:    

Week 15: 5/2-5/3

Topics: wrapup

   

Mon Examples:    

Tue      

Exams: 5/7-5/10

   

Sat    

Sun    

Mon    

Tue
exam #3
Tue 5/10 7-10pm
end-of-semester deadline
no work accepted after 5/10 10pm

Valid HTML 4.01!