CPSC 124 Introduction to Programming Spring 2018

CPSC 124 Schedule

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: 1/17-1/19

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

     

Wed Slides: course introduction      

Thu Reading: Eck, introduction to section 2.6 and 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 Thu 1/25

(comments)
 

Fri Reading:

Slides: building blocks (computers running programs, program structure)

warmup #1
(on Canvas, in the "Quizzes" section)
due Thu 11:59pm
 

Week 2: 1/22-1/26

Topics: basic building blocks; algorithms

   

Mon Reading:
  • Eck sections 2.3.1-2.3.3, 2.4.1-2.4.3, 2.5.1-2.5.2, 2.5.6-2.5.7 [reading guide]
  • optional reading: Eck sections 2.4.4-2.4.5

Slides: more building blocks (expressions, type conversion, built-in subroutines, input)

warmup #2
(on Canvas, in the "Quizzes" section)
due Sun 11:59pm
 

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)

Slides: constructing programs

Examples:

   

Thu   lab 2
First Programs

due Thu 2/1

(comments)
 

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

Slides: big picture (overview of the topics in the reading)

Examples:

warmup #3
(on Canvas, in the "Quizzes" section)
due Thu 11:59pm
 

Week 3: 1/29-2/2

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.4 first)

Slides: conditionals (overview, program development with ifs)

Examples:

  • MathQuiz.java (program development with ifs) - note, functionality not complete
warmup #4
(on Canvas, in the "Quizzes" section)
due Sun 11:59pm
 

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

   

Thu   lab 3
Conditionals

due Thu 2/8

(comments)
 

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

Slides: loops (overview, program development with loops)

Examples:

  • Print100.java (section 01 version - unit of repetition is "print a number")
  • Print100alt.java (section 02 version - unit of repetition is "print a line of numbers")
warmup #5
(on Canvas, in the "Quizzes" section)
due Thu 11:59pm
 

Week 4: 2/5-2/9

Topics: loops; arrays

   

Mon Examples:
  • Sum.java (loops, something-so-far pattern)
  • Max.java (loops, something-so-far pattern)
  • Max2.java (if-we-only-had-a-variable tactic)
   

Wed Reading:

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.

Slides: loops (loop patterns)

Examples:

warmup #6
(on Canvas, in the "Quizzes" section)
due Tue 11:59pm
 

Thu   lab 4
Loops

due Thu 2/15

(comments)
 

Fri Reading:
  • Eck sections 3.8.1-3.8.3 [reading guide]
  • optional reading: Eck section 7.1.1

Slides:

Examples:

warmup #7
(on Canvas, in the "Quizzes" section)
due Thu 11:59pm
 

Week 5: 2/12-2/16

Topics: arrays; programming with loops and arrays

   

Mon Reading:
  • Eck section 4.7.1
  • Eck section 7.1.3

Slides:

Examples:

   

Wed Reading:
  • Eck section 3.8.5 [reading guide]
  • optional reading: Eck section 7.5

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.

Slides:

Examples:

warmup #8
(on Canvas, in the "Quizzes" section)
due Tue 11:59pm
 

Thu   lab 5
Arrays

due Thu 2/22

(comments)
 

Fri Slides:

Examples:

   

Week 6: 2/19-2/23

Topics: subroutines

   

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

Slides:

Examples:

warmup #9
(on Canvas, in the "Quizzes" section)
due Sun 11:59pm
project 1
Battleship

muddiest points due Wed 2/21

Wed Reading:

Slides:

Examples:

warmup #10
(on Canvas, in the "Quizzes" section)
due Tue 11:59pm

Thu Slides: battleship muddiest points     project 1
Battleship

pseudocode due Tue 2/27

pseudocode

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.

Slides:

Examples:

 

Week 7: 2/26-3/2

Topics: subroutines

 

Mon
midterm #1
Mon 2/26 in class
 

Wed Reading:

Slides:

Examples:

warmup #11
(on Canvas, in the "Quizzes" section)
due Tue 11:59pm
  project 1
Battleship

program due Fri 3/16

(comments)

Thu   lab 6
Subroutines and Functions

due Thu 3/8

(comments)

Fri Slides:

Examples:

 

Week 8: 3/5-3/9

Topics: program design with subroutines; odds and ends; exceptions; using objects

 

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:

 

Wed Reading:

Slides:

Examples:

warmup #12
(on Canvas, in the "Quizzes" section)
due Tue 11:59pm

Thu   lab 7
Programming With Subroutines

due Thu 3/15

Fri Reading:
  • Shiffman, Learning Processing, pages 121-123 (Shiffman-objects.pdf in the "Files" section on Canvas) [reading guide]
  • Eck section 1.5 [reading guide]

Reference:

Slides:

Examples:

warmup #13
(on Canvas, in the "Quizzes" section)
due Thu 11:59pm

Week 9: 3/12-3/16

Topics: objects and classes

 

Mon Reading:

Reference:

Slides:

Examples:

warmup #14
(on Canvas, in the "Quizzes" section)
due Sun 11:59pm

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 javadoc API of any classes you are to use (including Card, Deck, Hand).

Slides:

Examples:

warmup #15
(on Canvas, in the "Quizzes" section)
due Tue 11:59pm

Thu   lab 8
Using Objects

due Thu 3/29

(comments)

Fri Reading:

Slides:

Examples:

 

Spring Break: 3/19-3/23


Week 10: 3/26-3/30

Topics: objects and classes; program design with classes

   

Mon Slides:

Examples:

   

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:

   

Thu   lab 9
Writing Classes

due Thu 4/5

(comments)
 

Fri Reading:

Slides:

warmup #16
(on Canvas, in the "Quizzes" section)
due Fri 11:59pm
 

Week 11: 4/2-4/6

Topics: partially full arrays, dynamic arrays, array lists; searching and sorting

   

Mon Reading: Slides:

Examples:

warmup #17
(on Canvas, in the "Quizzes" section)
due Sun 11:59pm
project 2
Pac-Man

muddiest points due Wed 4/4

Wed Reading: Slides:

Examples:

warmup #18
(on Canvas, in the "Quizzes" section)
due Tue 11:59pm

  project 2
Pac-Man

design due Thu 4/5
Thu Slides:     project 2
Pac-Man

program due Mon 4/16

(comments)

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

Slides:

Examples:

 

Week 12: 4/9-4/13

Topics: inheritance

 

Mon
midterm #2
Mon 4/9 in class
 

Wed Reading:

Slides:

Examples:

warmup #19
(on Canvas, in the "Quizzes" section)
due Tue 11:59pm

Thu   lab 10
Variable-Sized Collections

due Thu 4/19

(comments)

Fri Examples:  

Week 13: 4/16-4/20

Topics: inheritance and polymorphism

 

Mon Reading:

Slides:

Examples:

warmup #20
(on Canvas, in the "Quizzes" section)
due Sun 11:59pm
project 3
Connect Four

muddiest points due Tue 4/17

Wed 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/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.

Slides:

Examples:

  project 3
Connect Four

program due Tue 5/1

(comments)

Thu   lab 11
Inheritance

due Thu 4/26

(comments)

Fri Slides:

Examples:

 

Week 14: 4/23-4/27

Topics: GUI programming

 

Mon Reading:
  • Eck sections 1.6, 6.1-6.2, 6.5, 6.6.1 [reading guide]
  • optional reading: the rest of Eck section 6.6

Slides:

Examples:

Reference:

 

Wed Reading:
  • Eck sections 6.3.1-6.3.4, 6.4.4 [reading guide]
  • optional reading: the rest of Eck section 6.4

Slides:

Examples:

Reference:

 

Thu Solutions for the lab exercises:   Introduction to GUIs
due at the end of lab

Fri Examples: (part of exercise #3 from yesterday)  

Week 15: 4/30-5/1

Topics: GUI programming/wrapup

 

Mon Slides:  

Tue  

Reading Period and Exams: 5/2-5/8

   

Wed    

Thu    

Fri    

Sat      

Sun
final exam (section 2)
Sun 5/6 1:30-4:30pm
end-of-semester deadline (section 2)
no work accepted after 5/6 4:30pm

Mon      

Tue
final exam (section 1)
Tue 5/8 1:30-4:30pm
end-of-semester deadline (section 1)
no work accepted after 5/8 4:30pm

Valid HTML 4.01!