Advanced Placement Computer Science


Course Overview
Course Policies
West Torrance Page
   Syllabus
   Class Schedule
   Homework
   Labs
   Projects
   Extra Credit
   Grades
Peninsula Page
Computer Science 2 AP
Get Software
Useful Resources
Teacher Information


Labs for Computer Science AP at West Torrance High School


  • Lab 1 - Due 10/2/03
    • You are to draw a full UML design to describe a video game, in this case the game "Super Mario Brothers" (TM).  The game could be described as a multitude of objects, including the following:  an enemy class that describes in the most generic terms what an enemy is, a goomba class which extends the enemy class and implements the way the gooma moves around and can hurt the heroes, a hammerturtle class that extends the enemy class similiarly, a bowser class that extends enemy in the same way; a hero class which defines in general terms what a hero is, how they can die, how they keep score, a Mario class that extends the hero class and describes how to draw Mario, a Luigi class which extends the hero class and describes how to draw Luigi.  You also have a music class which plays music.  You also have a level class which will use objects of type goomba, hammerturtle, bowser, music, and Luigi.  Add in any methods that make sense to you that they belong in the class.   This lab is worth 2 points and is to be handed in at the end of class.
  • Lab 2 - Due 10/7/03 - possible solution
    • Do exercises 2.44 & 2.45 in the text.  This is a partnered lab, meaning you may work with 1 other student in your class.  This lab is worth 4 points and is to be handed in by the end of the class (you can be graded earlier though) on 10/7/03.
                Tips!
    • For 2.44, you might want to break the problem down into two pieces.  #1 find out which is the first slot that has a cd in it.  #2 take that cd and put it on the stack.  Thanks to the precondition you know that there must be a cd in the first four slots, so don't bother checking beyond the first four.
    • For 2.45, you need to get rid of the precondition.  The precondition says that you should assume that 2 of the first 3 slots have a cd in it.  If you get rid of that precondition that means you need to ensure that at least 2 of the first 3 slots have a cd in it.  That means you need to write code to check that indeed, 2 of the first 3 slots have a cd.  Ask yourself how many possible ways there is to have at least 2 of 3 slots filled, and check for them.  (hint:  there are 3 ways).  If any of those 3 ways is true then run the code that is already in listing 2.11. 
  • Lab 3 - Due 10/10/03
    • Create a method that will reverse the order of 4 cds in a Vic sequence.  Your precondition is there is a sequence with at least the first four slots filled with cds.  You are to take the cd in slot 4, move it to slot 1, the cd from slot 3 and put it in slot 2, the cd in slot 3 and put it in slot 2, the cd in slot 1 and put it in slot 4.  Hint:  You need not do the problem in this order, and you might want to use the stack of cds to your advantage by placing more than 1 of the cds on it at a time....  (though you can solve this however you choose)  In theory this can be solved with about 13 lines of code in a method.  This is a partnered lab and worth 3 points.

last updated on 10/10/03
Copyright (C) 2003 Jim Casaburi