CST 310: Computer Science Languages

School of Professional Studies

Saint Louis University , Saint Louis, Missouri



Best viewed through Internet Explorer because of Word and Powerpoint content.


Index

Lecture Notes
Assignments
Solutions and code examples
Configuring samples
Instructions on mailing code
Errata
Meeting times, dates, and place
Syllabus
Frequently asked questions
Miscellaneous Information
Useful links

Lecture Notes

Lecture 2

Lecture 1


Assignments


Assignment 5:

Reading: Chapters 12, 13, and 14 from Java: First Contact

Programming:
(1) Problem 3 and 6 of Chapter 7, Java: First Contact
(2) Problem 3, 4 and 5 of Chapter 8, Java: First Contact


Assignment 4:

Reading: Chapters 7 from Java: First Contact

Programming:

(1) Problem 1 of Chapter 5, Java: First Contact

(2 and 3) Problem 2 and 3 of Chapter 6, Java: First Contact

(4) Write a program that sums a sequence of integers. The first integer read specifies the number of integers remaining to be entered.

Here are two examples:

Example 1

3
10
60
5

The sum of the 3 numbers is 75.

Example 2

5
100
10
100
50
500

The sum of the 5 numbers is 760.

(5) Write a program that sums a sequence of integers. The end of the sequence will be specified with a -1.

Here are two examples:

Example 1

10
60
5
-1

The sum of the 3 numbers is 75.

Example 2

100
10
100
50
500
-1

The sum of the 5 numbers is 760.


Assignment 3:

Reading: Chapters 5 and Chapter 6 from Java: First Contact

Programming: Problem 2, 3, 4, 5, and 6 of Chapter 4, Java: First Contact


Assignment 2:

Reading: Chapters 4 from Java: First Contact

Programming: Problem 3, 4, and 5 of Chapter 3, Java: First Contact


Assignment 1:

Reading: Chapters 1, 2, and 3 from Java: First Contact

Programming:
(1) Last problem of Chapter 1, Java: First Contact
(2) A simple program that prints out your name, phone number, and social security number.


Solutions and code examples

Homeworks

Chapter 8: Ex 3, Ex 4, Ex 5 and the Car, Cooker, and Dish classes.

Chapter 7: Ex 3, Ex 6 and the Journey class.

Chapter 6: Ex 2, Ex 3

Chapter 5: Ex 1, Summing integers (when user specifies the number of integers), Summing integers (until user specifies -1)

Chapter 4: Ex 2 , Ex 3 , Ex 4 , Ex 5 , Ex 6

Chapter 3: Ex 3 , Ex 3 (cool version) , Ex 4 , Ex 5

A simple program that prints out your name, phone number, and social security number.

Quizzes

Quiz 5 (programming) and suppliment code : Solution

Quiz 4 (programming) : Solutions Version 1, Version 2

Quiz 3 (written) : Solution.

Quiz 3 (programming) and suppliment code : Solutions part (a), part (b)

Quiz 2 : Solution.

Quiz 1 : Solution.

Examples

Graphical User Interface (GUI) application:
This Adder application is an example of a GUI application (without having to be an applet)

Fun Applet:
Genie applet: code and applet

Advanced Applets:
CardShow example shows the use of the Choice GUI object. It also shows the how to download images into an applet: code and applet ( images of cards used in this example)

Applets:
BeanJar example (from our last class): code and applet

Persistence:
Example of persistence (storing objects to disk and reading objects from disk) through the PersistentPeople class.

Chapter 12:
Example of inheritance through the extended Person class: PersonWithAddressInfo

Chapter 9:
Example of a collection of Person objects through the use of the Vector class.

Chapter 7 and 8:
Example of Person class: Version 1, Version 2, Version 3, Version 4
Example of Rectangle class.

Chapter 5:
Example of for loops: (1) simple, (2) summation of integers from 1 to number, (3) nested for loops
Example of while loops: (1) Original greetings program, (2) Greetings with while loop, (3) Greeting with while and break

Chapter 4:
Person classification (uses if/else statements)
Greetings (uses switch/case statements)

Chapter 3: Sample from book

Java: First Contact.


Configuring samples from Java: First Contact

1. Click
here to get the distribution.

2. When the File Download box appears, choose Run this program from its current location.

3. Click Yes when the Security Warning appears.

4. Type c:\cst310 in Unzip to Folder in the WinZip dialog.

5. Move the .class files from c:\cst310\Disk1\classes\bytecode to c:\cst310\java\lancs. This can be done by doing the following from the command prompt (cmd):

E:\irfan> c:
C:\WINNT> cd \cst310
C:\cst310> mkdir java
C:\cst310> mkdir java\lancs
C:\cst310> move Disk1\classes\bytecode\* java\lancs

6. In Visual J++, under:

Project -> Setting -> General -> Class path directories

add:

c:\cst310

Your final string under Class path directories may look like this:

c:\winnt\java\classes\classes.zip;c:\cst310

7. (Optional): If you want to run jview from the command line, add c:\cst310 to your CLASSPATH variable:

set CLASSPATH=c:\cst310


Instructions on mailing code

Please mail your .java files to the teaching assistant before the start of class.


Meeting times, dates, and place

Timing: 5:30pm to 9:30pm on Tuesday nights

Dates: 10/27, 11/3, 11/10, 11/17, 11/24, 12/1, 12/8, and 12/15

Place: Room 1066, McDonnell Douglas Hall, Frost Campus, Saint Louis University

Note: 11/5 session has been cancelled for now. It will be reschedule later on in the semester.


Syllabus

Syllabus includes a description of course, meeting times, grading policy, etc.


Frequently asked questions


Question: I get this error when I compile my program:

error J0051: Undefined package 'lang'

Answer: The fix is to add the following line to:

Project -> Setting -> General -> Class Path directories:
c:\winnt\java\classes\classes.zip

Note: Since I use Windows NT, my system path is c:\winnt. For some people, it might be c:\windows or c:\win95.


Question: How do I run my Java program from the DOS prompt?

Answer: You can run your Java program from the DOS prompt by running the Java interpreter (jview.exe) by hand. Here is an example:

E:\irfan\SLU\cst310\Simple> c:\WINNT\jview.exe simple.class


Miscellaneous Information

Instructor: Irfan Pyarali
Office Phone: (314) 935-7492
Home Phone: (314) 993-7114
E-Mail:
irfan@cs.wustl.edu
WWW: http://www.cs.wustl.edu/~irfan

Teaching Assistant: Hung Tang
Applied Computer Science
Parks College of Saint Louis University
E-Mail: tanghp@sol.slu.edu


Useful links

Java Development Kit from Sun

Java Development Kit from Microsoft

Documentation for standard Java packages

The Java Language Specification


Errata

The installation procedure in the trial version of Visual J++ is somewhat flaky. It sometimes leaves out the classes.zip file from the c:\windows\java\classes directory. Please download classes.zip and place it in under the c:\windows\java\classes directory. Note that depending upon your system, c:\windows maybe be c:\win95 or c:\winnt.

Chapter 3, Question 5 requires the use of the GregorianCalendar class. Unfortunate, this class is missing from the Java Virtual Machine from Microsoft. To rectify this situation, please do the following:

- Create directory c:\cst310\java\io
- Create directory c:\cst310\java\util

Then install:

- Serializable.class under c:\cst310\java\io
- Calendar.class under c:\cst310\java\util
- GregorianCalendar.class under c:\cst310\java\util

Some people may also need these:

- TimeZone.class under c:\cst310\java\util
- TimeZoneData.class under c:\cst310\java\util

Chapter 4, Question 5 requires the use of Card::Card(int s, int v). However, there is a bug in the Card class. Please download this version of Card.class and save it under c:\cst310\java\lancs. This means that you will be overwriting the old version of Card.class.

If you are missing other files, please check here. If you cannot find the file you are looking for, please let the instructor know.

If you are having problems using the BasicIo class, take a look at this example for an alternate way of obtaining input from the user.