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


Computer Science AP at West Torrance High School



Announcements!

10/5/03
  • Instructions for how to get reset working correctly in the Vic class.  (taken from the class forum)
Ok, there is a lot of misinformation out there on reset. Some of it is caused by small mistakes in the book, some of them caused by myself.

reset () is a static method built into the Vic class that takes in an array of Strings as its arguments. What are those? They are a bunch of pieces of text. We haven't covered how to handle those yet, though we will. Right now you only have handy access to a single type of array of strings, namely the command-line parameters signified by the String[] args in your main method.

If you ever see a reset() with no arguments, either the book is assuming another copy of reset exists, or it is a mistake.

The only method (pun not intended) to specify how many slots are available and which are populated is to use that args variable in main. For instance, given the following code in a class:

public static void main(String[] args) {
Vic myvic;
myvic = new Vic();
Vic.reset(args);
}

you cannot (easily) directly specify the value for reset, but you can pass that information in two ways:

if you are compiling this for a command line (let's assume the java file is called myfile.java) you'd type the following:
javac myfile.java Vic.java
java myfile 1001

that creates a sequence with 4 slots, with the 1st and the 4th slot filled with a cd. To change it to be 5 slots, with each one filled, you would type the following:
java myfile 11111

If you are doing this through bluej, it is much the same except you feed the information for args a little bit differently. When you right click on the class and pick out void main it will ask you what information to feed it.
You type it in in the following fashion: to have 5 slots, each one filled, type in {"11111"} into the box provided then hit ok
To have 4 slots, each one empty, type in {"0000"} and for 5 slots, only the 2nd on filled type {"01000"} and so forth.


9/15/03
  • Instructions on how to get turtle compiling
For BlueJ to get programs using Turtle running, add Turtle.java and Turtlet.java into your project. (click on edit->add class from file)  Once there you can compile the files and create a new class that uses the Turtle objects. 


For command-line compiling, you need to copy Turtle.java and Turtlet.java into the directory that the .java file you want to compile is.  Assuming your .java file is named MyClass.java you would type the following at the command prompt.

javac Turtlet.java Turtle.java MyClass.java

replace MyClass with whatever your .java file is actually named (remember, it will also be named exactly the same as the name of your class, and also remember that capitilization matters!)

once you have done that you can run your program as follows

java MyClass

Again, replace MyClass with whatever the correct name is, and this assumes you have a method defined within the class called main declared as a public static method with arguments of String[] args
(the declaration would start with public static void main(String[] args) {    )

Note:  at this point, it is probably much easier to deal with BlueJ than the command-line.


9/10/03




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