CS11a: Intro to Programming in Java and C
Welcome

· General Information
· Description
· Syllabus
· Grading

· Notes

  (printable)
Padding

 

Instructor: Tim Hickey
Office hours:in Volen 138, 10-11 Thu, 2-3 Fri, also by appointment
Text: "Java: An Introduction to Computer Science and Programming", 4th ed. (Savitch)

Textbook Run GrewpEdit code from class TA hours WebCT mailing list

Homework

  • HW1 due Friday 9/9/2005 before 5pm
  • HW2 due Friday 9/16/2005 before 5pm
  • HW3 due Thursday 9/29/2005 before 5pm
  • HW4 due Friday 10/14/2005 before 5pm
  • HW5 due Monday 10/31/2005 before 5pm
  • HW6 due Tuesday 11/15/2005 before 5pm
  • HW7 due Friday 12/2/2005 before 4pm
  • HW8 due Friday 12/16/2005 at 9am

Quizzes and Exams

Class Notes

Week 16

Fri. 12/16/2005

FINAL EXAM. 3 hour. 9:15am-12:15. Open book/open note, no electronic devices.

Mon. 12/12/2005

Review

Today we went over the Final Exam Study Guide and the Course Evaluation forms were also completed.

Week 15 -- more C programming

Thu. 12/08/2005

Today we continued our discussion of strings in C and Java and we started writing a program jstring.c to implement Java style strings in C.

Wed. 12/07/2005

Today we continued discussing structures in C.

Mon. 11/05/2005

Today we talked about structures in C and we wrote two sample programs structdemo.c and structdemo2.c.
Week 14 -- C programmming

Thu. 12/01/2005

Today we continue with string processing in C and we discuss also character input/output and pointer arithmetic. We wrote a program, stringdemo.c to process C-style strings.

Wed. 11/30/2005

Today we discussed string processing in C and contrasted it to string processing in Java. We started working on a demo program here.

Mon. 11/28/2005

Today we provide an introduction to programming in C. Here is a C Library Reference Guide" that gives a brief overview of the C language and its standard libraries. We will spend the next two weeks showing how to translate the Java programs we've written this semester into C. Here is the code we wrote today.

Week 13

Thu. 11/24/2005 Thanksgiving

Wed. 11/23/2005 Day of low attendance

Class will be online using GrewpEdit!!

Today we go over the answers to Quiz5 and look at the generated javadoc Documentation.

Then, we formally introduce the notions of inheritance, subclasses, superclasses, interfaces, and protected members. This material is from Chapter 7, which you should skim.

We also go back to the ArrayList example (code and javadoc) and we show how inheritance and interfaces work together to allow one to write code that can be used with several different implementations of an abstract data type (e.g. ArrayList).

Mon. 11/21/2005

Arrays of Objects, Multi-dimensional arrays, and Quiz 5

Week 12

Thu. 11/17/2005

Today we look at two other approaches to implementing ArrayList (the code is here) and we discuss the use of inheritance and interfaces to minimize redundancy in code. We also show how to improve on the performance of getMin, getMax, getSum in the simple ArrayList implementation.

The quiz has been delayed until Monday. You should bring in a copy of Turtle.java for Monday's quiz (and its a good idea to also bring in copies of your solution to the homework problems, the quizzes, and the midterm as well!)

Wed. 11/16/2005

Continued working on the ArrayList class (available here. After writing all of the methods and testing them in the ArrayTest class, we analyzed the performance. The results are in the following table, where we are assuming that the ArrayList, a, contains n elements:

method            approximate number of steps needed
                  average      best-case    worst-case
a.listSize()      1            1            1
a.maxListSize( )  1            1            1
a.add(n)          2            2            2
a.getMin()        n            n            n
a.getMax()        n            n            n
a.getSum()        n            n            n
a.remove()        n            n            n
a.isInList()      n/2          1            n
So this implementation of Lists is best suited to applications where we are going to be adding many elements, deleting very few, and calculating the min, max, and average only occasionally.

Mon. 11/14/2005

Today we started writing the ArrayList class which uses an underlying array to represent a list of integers and which allows several actions on that list of integers. The purpose of this series of lectures is to give several examples of working with arrays as well as to provide more examples of defining and using instance variables and methods.

Week 11

Thu. 11/10/2005

More array demos, introduction to sorting algorithms (selection sort, insertion sort, merge sort, ...)

Wed. 11/9/2005

We started off showing how to generate java documentation of your code using the command

  % javadoc *.java
in the folder containing your java code.

Then we discussed passing arrays as parameters, returning arrays as values, method overloading. We developed the ArrayDemo.java program to demonstrate these ideas. Finally, we started to describe some of the simplest sorting algorithms.

Mon. 11/7/2005

Introduction to Arrays

Week 10

Thu. 11/3/2005

Completed discussion of Chapter 5 and went over HW6. Completed the Turtle code examples used in HW6.

Wed. 11/2/2005

Went over the midterm and gave Quiz 4

Mon. 10/31/2005

Worked on the Turtle.java class

Week 9

Thu. 10/26/2005

Continued with Turtle Graphics example. Discussed

  • Constructors (how to define, how to call, overloading)
  • Instance Methods (how to define, how to call)
  • Instance Fields (how to define, how to use)
  • Static Methods (how to define, how to call)
  • Static Fields (how to define, how to use)
In particular we showed how to add a "distance travelled" field to each turtle, and to also calculate and access the total distance travelled by all turtles.

We also discussed how to tell the difference between constructor calls, instance method calls, and static method calls:

 Constructors       --   Classname(argument,list)
 Instance Methods   --   objectVariable.methodName(argument,list)
 Static Method      --   Classname.methodName(argument,list)
 Instance Variable  --   objectVariable.fieldName
 Static Variable    --   Classname.fieldName

The code for todays lecture is in code/oct27. You need to download all four files and compile TurtleDemo.java to get it to run.

Wed. 10/25/2005

Static methods and variables. Constructors. Overloading method names. Refactoring.

Mon. 10/24/2005

Static methods and variables. Constructors. Overloading method names. Refactoring.

Click here for programs written in class.

Read Chapter 5 for this week. There will be a quiz on Thursday (Quiz 4) and HW5 is due Friday 10/28 before 5pm. We will assign HW6 on Thursday.

Week 8

Thu. 10/20/2005

Midterm exam

Wed. 10/19/2005

Midterm review

Mon. 10/17/2005

Accessor, Mutators, Instance variables and Instance methods

Week 7

Thu. 10/13/2005

No class -- Yom Kippur.

Wed. 10/12/2005

There will a quiz at the BEGINNING of class today. Don't be late.

Mon. 10/10/2005

Classes and Methods

Today we continue discussing Object Oriented Programming in Java. We continued with the FirstSpecies examples and then started an example writing a class to represent Intervals. All of the code is in code/oct10. Also, the due date for hw4 has been pushed back to Friday as many students are having multiple midterms this week. (Read Chapter 4).
Week 6

Thu. 10/6/2005

Introduction to Methods

Resources for this lecture:

Wed. 10/5/2005

No Class - Rosh Hashana

Mon. 10/3/2005

No Class - Brandeis Tuesday schedule in effect

Week 5

Thu. 9/29/2005

Today we go over HW4, answer questions, and give quiz 2. Time permitting we will write some additional programs involving loops. Note: the next class will be on Thursday 10/6 after Rosh Hashana.

Wed. 9/28/2005

Today we continue discussing loops and look at several loop patterns. The programs we wrote are available in code/sep28.

Also, the class webct site now has online grades and an onlne forum for holding online discussions about Java and CS11a. There will be an in-class quiz tomorrow similar to the problems in HW3.

Mon. 9/26/2005

Today we introduced loops and discussed while, do-while, and for loops The code is in code/sep26.

Week 4

Thu. 9/22/2005

Today we answered questions about the homework and gave quiz 1

Wed. 9/21/2005

Today we wrote four programs in class demonstrating the use of the if, if-else, and switch statements as well as conditional expressions. The code is here in the course code repository.

Mon. 9/19/2005

Today we wrote three programs in class demonstrating the use of the if and if-else statements. The code is here in the course code repository.

Week 3

Thu. 9/15/2005

Today we wrote two sample programs in class. They are both available here in the course code repository.

We demonstrated that step-wise refinement method of code development where you break the programming project down into a sequence of intermediate projects. The first step is to write a simple program that just prompts the user for some input. You debug that program and then extend it by having it get the input from the user and then echo it back to the user. Debug this and then continue extending. The idea is that rather than writing one large program (which may be filled with bugs) and then debugging it (which can be challenging). One writes a simple program and then incrementally makes small extensions to it, debugging each of the intermediate programs. The advantage of this approach is that each programming task is relatively small. Moreover, debugging is easier as you only have to look for errors in the code that was just added to the program. Actually, new code may sometimes uncover errors in earlier code, but its not common!).

We also demonstrated the use of public static final variables for storing CONSTANT values.

Wed. 9/14/2005

Today we continued our discussion of String manipulation and we wrote three programs (available here) illustrating these ideas. Also, our TA Devon Krisman has posted some instructions on using GrewpEdit on PCs.

Mon. 9/12/2005

Today we discussed the division and remainder operations and went over the CoinDemo program. Then we introduced String processing and wrote a StringDemo program that showed how to apply several instance methods to a string s: s.length() s.equals("hello") s.indexOf("Brandeis") s.substring(0,10) s.substring(18) The sample programs are avaiable in this folder
Week 2

Thu. 9/8/2005

Today we looked at techniques for writing programs that prompt the user for input, read the numbers the user types, and the prints are response created using those input numbers. The sample programs are avaiable in this folder

Wed. 9/7/2005

For this week, read Chapter 2: Primitive Types, Strings, and Console I/O. For people use 3rd edition or using Macs, you'll need to use the file SavitchIn.java to support reading from the keyboard...

Week 1

Thu 9/1/2005

We wrote the Hello World program and showed how to compile and run it using the GrewpEdit tool.

2004 © Copyright Tim Hickey, Some Rights Reserved