Tutorial 1 Lecturer: Ray Reiter Tutor: Andria Hunter ========== 990106 Wed@1pm (PA105) CSC148, Spring 1999 Tutorial notes, T1 ================================================================== Topics: ------------------------------ - Introduction - Using the system (briefly) - Java packages - Java refresher - Java classes, and static instance members List of TAs and rooms ------------------------------ - This tutorial section is for students whose last name starts from Sin-Z and who have Ray Reiter at 1:10 pm. Introduction ------------------------------ - Introduce yourself. (Write your name on the board - they'll need to know your name if they want to get their assignments back! :-)) - did my MSc in Computer Science here at UofT - did my BSc in Computer Science at UNH on a hockey scholarship - 2 world championships with Team Canada! - TAed many courses at UofT, but never 148 - How many of you have taken CSC108? No Java experience? - Feel free to say a few words about what you hope tutorials will be like: - purpose is not to present new material - bring your questions! Don't be shy ... chances are the person sitting next to you has the same question! - Other places for extra help - Read the PC-HOTO GUIDE - system info & starting JavaWorkshop - Do the online homework examples - TA office hours in the lab - Instructor office hours Using the System ------------------------------ - Very briefly go over these system basics: - login and logout - web & newsgroups - send and read mail - printing - disks on CDFPC - Java Workshop Java Packages ------------------------------ - We rely heavily on Java packages this term. The students didn't see much of them in 108, so it'll be pretty new to them. - The course web page has info on exactly how to set up Java WorkShop to manage packages for assignment 0 (although it is not required for assignment 0). The course web page also contains lecture notes that explain packages more. Java Refresher ------------------------------ - Get to class a minute or two early and put this up: public class Example1 { public static void main( String[] args ) { // Add the integers 1 through 5 and print the result. int result = 0; // >> The for loop goes here. << } } - Have them write the loop, in small groups if you want. Let them work on it for about 2 minutes and walk around and talk to them during that time, then go to the board and have them tell you what to write. - Some of them won't know Java. Tell those students to write it in the language of their choice, but do only Java on the board. Java classes ------------------------------ - Here is an example that uses an array of objects... public class Student { private String myName; private int myID; public Student( String name, int id ) { myName = name; myID = id; } public void setName( String newName ) { myName = newName; } public String getName() { return myName; } public void setID( int newID ) { myID = newID; } public int getID() { return myID; } } public class Section { private Student[] students; private int numStudents; public Section( int numStudents ) { students = new Student[numStudents]; } public void addStudent( Student s ) { students[numStudents++] = s; } public Student findStudent( int id ) { for (int i=0; i