COMPUTER SCIENCE
Summer 2007
- Java Curriculum at TJ
- Computer Science at TJ
- 1st Quarter
- Course materials
- Running your first program (sys lab version)
- Calendar, assignments, quizzes: Unit 1
- Day 1, Monday July 9
- Using Java, Lab00: Hello Robot (Program Structure), Class Robot
- Lab01: Student and Teacher, returning the "beeper" to the "bookroom", Class Robot, turnLeft(), move(), pickBeeper(), putBeeper().
- Exercises Lab01 p. 8 1-5, 7-10
- Lab02: Escape the Maze. Class Athlete extends Robot. Athlete is a specialized Robot, adds methods turnRight(), turnAround(), and new constructors.
- Writing your own constructors, using "super" to call an extended class' constructor
- Look at for loops p. 20
- Exercises Lab02 p. 11 1-4
- Lab03: Climb Every Mountain. Class Climber extends Athlete. Climbers can also climbUpRight(), climbUpLeft(), climbDownRight(), climbDownLeft(), and a new constructor for Climbers sending only the x coordinate.
- Day 2, Tuesday July 10
- Lab04: Take the Field, uses Class Athlete.
- class methods vs instance methods.
instance method examples: turnRight(), turnAround() - all Athletes know how to turnright and turnaround.
class method example - specialized for a particular program such as Lab04 and takeTheField().
takeTheField(maria) vs maria.turnRight()
- Look at constructors again
- Exercises Lab04 p. 17 1-9 and Exercises pt. 2 Lab 04 1,4
- Lab05: Shuttle Run. Class Racer extends Athlete.
Racers can jumpRight(), sprint(n) spaces, put(n) beepers, and pick(n) beepers. Also define a new constructor sending only the y coordinate.
- Exercises - Boolean methods p. 23 1-7
- Lab06: Half-Dozen Tasks - using Boolean methods: while(temp.frontIsClear()) ...
Note - for Systems Lab: use World.readWorld("worlds/" + filename + ".wld");
- Exercises Lab06 p. 25
- Lab07: Exploration. Class Climber (climbs mountains), HillClimber (climbs hills), StepClimber (climbs steps)
Mountains are "up 2 over 1". Hills are "up 1 over 2". Steps are "up 1 over 1".
Introduces polymorphism - the behavior of a particular method (command) depends on the kind of object the method is using.
climbUpRight() behaves differently for Climber, HillClimber, StepClimber
- 3 mountain worlds - start on 8. 3 hill worlds - start on 10. 3 step worlds - start on 12
- Quiz Labs00-04, in the afternoon
- Day 3, Wed. July 11
- Lab06/07:
- Instance methods vs class methods (static)
- Inheritance, "extends", and polymorphism
- while loops p. 22, using Boolean method calls
- Exercises Lab07
- Polymorphism discussion p. 28
- Online exercise Lab07
- Lab08: Hurdle Racing. SteepleChaseRacer and BoxTopRacer extend Racer.
Hurdles are straight vertical lines 1 block high, Racers jump Hurdles.
Steeples are straight vertical lines n blocks high, SteepleChaseRacers jump hurdles
BoxTops box shaped, n blocks high and n blocks across. BoxTopRacer jump BoxTops.
- Review Polymorphism - the jumpRight() method behaves differently for various kinds of "racers"
- Exercises Lab08 p. 30 - Polymorphism, dynamic method binding.
- Look at Lab09: Shifting Piles - a Robot shifts piles of various numbers of beepers
- Day 4, Thursday July 12
- Unit 1, Lab09:Shifting Piles and Lab10: Maze Escaping
- Exercises Lab09, p. 32
- if statements, p. 22 and if/else p. 33
- Threads - running more than one Robot simultaneously
Math.random()
- Exercises Lab10, p. 35
- Quiz on Lab04-Lab08, afternoon
- Lecture Hall with Mr. Torbert
- Day 5, Friday July 13
- Finish up Unit 1 JKarel Programming
- Lab11: Identfication Numbers. Extending abstract classes
- Interfaces
- Lab12: Harvesting and Carpeting - Class Harvester (picks up a pattern of beepers) and Class Carpeter (lays down a pattern of beepers)
- Lab13: an original JKarel program - design one of your own
- Lab14: Synchronized Swimming - Class Swimmer. Parallel programming - using Threads and interface Runnable to have multiple Robots "swimming" at the "same" time.
- Lab15: Dancing Robots - class BackAndForthDancer, parallel programming using interface Runnable and Threads to have multiple "dancing" robots at the "same" time.
- Quiz on Lab00-Lab12
- Extra programs: Lab16: Shifty Robots, Lab17: Follow Walls, Lab18: Treasure Hunt, Lab19: Yellow Brick Road
- Start Unit 2: Graphics and Animation
- Using classes JFrame and JPanel for graphics.
- Driver class, with main(), creates a JFrame which will load a JPanel object
- The resource class, Panel00 for example, uses a JPanel and a Graphics object, g, upon which to draw graphics.
- Setting new fonts and colors using the classes Font and Color and the graphics object g
- Graphics shapes to draw: lines, rectangles and filled rectangles, circles and ellipses, polygons, polylines (not a completely finished polygon - last two vertices are unconnected)
- Using loops in graphics to draw multiple lines for a fence