CPSC 124 Introduction to Programming Fall 2013

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 tentative and may shift slightly.

 Assignments

Week 1: 8/26-8/30

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

     

Mon Notes: course introduction      

Tue Reading: Eck sections 2.6.1-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 Sep 3
 

Wed Reading:

Examples:

  • GasCostCalc.java (basic program structure, declaring and using variables, output)
warmup #1
due Tue 11:59pm
 

Fri 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:

warmup #2
due Thu 11:59pm
 

Week 2: 9/2-9/6

Topics: basic building blocks; algorithms; conditionals

   

Mon 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)

Notes: program development

Examples:

   

Tue   lab #2
First Programs
due Tue Sep 10
 

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

Examples:

warmup #3
due Tue 11:59pm
 

Fri 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
due Thu 11:59pm
 

Week 3: 9/9-9/13

Topics: conditionals and loops

   

Mon 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"
    otherwise if x is between 101 and 200,
      print "B"
    

(Note that in pseudocode like this, the indentation matters.)

Examples:

warmup #5
due Sun 11:59pm
 

Tue   lab #3
Control I
due Tue Sep 17

(comments)
 

Wed Notes: program development, 'if' questions, loop questions

Examples:

   

Fri Reading:
  • Eck section 3.4.3 [reading guide]
  • optional reading: Eck section 3.4.4 (you should read section 2.3.3 first)

Examples:

  • Max.java (loops, loop questions, finding a max)
  • MathQuiz4.java (loops, loop questions, error-checking user input)
warmup #6
due Thu 11:59pm
 

Week 4: 9/16-9/20

Topics: loops, arrays

   

Mon 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 may need to declare loop variables. You can write a while loop or a for loop.

Examples:

   

Tue   lab #4
Control II
due Tue Sep 24
 

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

Examples:

warmup #7
due Tue 11:59pm
 

Fri Examples:    

Week 5: 9/23-9/27

Topics: arrays, subroutines

   

Mon Reading:
  • Eck sections 7.5.1-7.5.2 [reading guide]
  • optional reading: Eck section 7.5.3 (the example includes things we haven't covered yet - focus on how the array is used)

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:

warmup #8
due Sun 11:59pm
 

Tue   lab #5
Arrays
due Tue Oct 1
 

Wed Examples:    

Fri Reading:
  • Eck sections 4.1-4.2.3 [reading guide]
  • optional reading: Eck section 4.2.4 (while occasionally useful, static member variables are, in many cases, not the best way to solve a problem)
Examples:
warmup #9
due Thu 11:59pm
 

Week 6: 9/30-10/4

Topics: subroutines

   

Mon Reading: Examples: warmup #10
due Sun 11:59pm
 

Tue     project 1
Battleship
pseudocode due Mon Oct 7
program due Fri Oct 18

Wed
exam #1
Wed 10/2 in class
   

Fri Reading:

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

  • Write the header (comments and 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
due Thu 11:59pm
 

Week 7: 10/7-10/11

Topics: subroutines and functions

   

Mon Reading:

Examples:

warmup #12
due Sun 11:59pm
 

Tue   lab #6
Subroutines and Functions
due Tue Oct 22

Wed Examples:  

Fri 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" subroutine.

Examples:

 

Week 8: 10/14-10/18

Topics: odds and ends, using objects

 

Mon fall break
(no class)
Tue

Wed Reading:

Examples:

no warmup

Fri Reading:

Examples:

warmup #13
due Thu 11:59pm
 

Week 9: 10/21-10/25

Topics: objects and classes

   

Mon Reading:

Examples:

warmup #14
due Sun 11:59pm
 

Tue   lab #7
Using Objects
due Tue Oct 29
 

Wed Reading:

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:

warmup #15
due Tue 11:59pm
 

Fri Reading:

Examples:

no warmup  

Week 10: 10/28-11/1

Topics: objects and classes

   

Mon 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:

   

Tue   lab #8
Writing Classes
due Tue Nov 5
 

Wed Reading:

Examples:

warmup #16
due Tue 11:59pm
 

Fri Examples:    

Week 11: 11/4-11/8

Topics: partially full arrays, dynamic arrays, array lists

   

Mon Reading:

Examples:

  • TileBag.java (partially full arrays, adding at end, removing in middle without preserving order)
  • TileRack.java (partially full arrays, adding at end, removing in middle while preserving order)
warmup #17
due Sun 11:59pm
 

Tue     project 2
Pac-Man
design due Wed Nov 6
program due Tue Nov 19

(comments)

Wed Reading:

Examples:

Reference:

warmup #18
due Tue 11:59pm
 

Fri
exam #2
Fri 11/8 in class
   

Week 12: 11/11-11/15

Topics: searching and sorting, 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 Nov 19

Wed Reading:

Examples:

warmup #19
due Tue 11:59pm

Fri Examples:  

Week 13: 11/18-11/22

Topics: inheritance and polymorphism; GUI programming

 

Mon Reading:

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 10/28 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 #20
due Sun 11:59pm

Tue   lab #10
Rabbit Hunt
due Tue Nov 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:
warmup #21
due Thu 11:59pm
project 3
Connect Four
due Wed Dec 11

Week 14: 11/25-11/29

Topics: GUI programming

 

Mon Notes: GUI programs, setting up the user interface

Examples:

More Information on GUIs:

 

Tue work on project    

Wed Thanksgiving break
(no class)
Fri

Week 15: 12/2-12/6

Topics: GUI programming; wrapup

   

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

Notes: handling events

Examples:

More Information on GUIs:

no warmup  

Tue work on project    

Wed meet in Gulick 208

Examples:

   

Fri Notes: from idea to program    

Reading Period and Exams: 12/7-12/13

   

Sat      

Sun    

Mon      

Tue    

Wed
exam #3
Wed 12/11 1:30-4:30pm
end-of-semester deadline
no work accepted after 12/11 4:30pm

Thu        

Fri        

Valid HTML 4.01!