|
COSC 1020 – Section M – Winter 2004 |
|
Instructor: Scott MacKenzie, CSB3045; Office Hours: MW 13:30-14:30 Last update: 31-Mar-04 |
Mar 31: Here
are the lecture notes from today’s class: misc.pdf, as
well as the demo programs presented: DaysToSummer.java
| DemoClock.java | DemoDateTime.java
| RandomBits.java | RandomQuilt.java
| GraphData.java Note: The last two applications
are applets, and must be viewed either using a web brower or using the appletviewer
application (e.g., using the command av RandomQuilt). Here
are the required html files RandomQuilt.html | GraphData.html
Mar 29: Here
are the lecture notes for chapter 12: chapter12.pdf
Mar 26: Here
are the lecture notes for chapter 11: chapter11.pdf
as well as the final demo program presented in class today: ExceptionHandling05.java
Mar 26: Marks
for Test #2 now posted. Use the courseInfo command to view. (See note posted on March 2.) The tests will be handed back in class
today.
Mar 24: Here
are the programs presented in class today: DemoCharFreq.java
| ExceptionHandling01.java | ExceptionHandling02.java | ExceptionHandling03.java | ExceptionHandling04.java
Mar 23: Click here
for solutions to Test #2. (Note: marks
will be posted soon.)
Mar 22: Here
are the lecture notes for Chapter 10: chapter10.pdf
as well as the demo program DemoWordFreq.java. The last slide in the notes presents the Programming
Challenge discussed in class today.
Please do this for Wednesday.
Mar 17: Here
are demo programs and associated files presented in class today: DemoArrayList.java | DemoHashSet.java
| DemoHashMap.java | sample.txt
| GulliversTravels.txt | d1-wordfreq.txt. Note: The file d1-wordfreq.txt is
derived from the British National Corpus.
The sample contains 67,962,112 total words, or 9,022 unique words. You can read more about the British National
Corpus from ftp://ftp.itri.bton.ac.uk/bnc/
Mar 15: Here
are updates to DemoToolkit.java and DemoCalendar.java programs.
For DemoToolkit, the
last line of output identifies the class of the Toolkit object returned by the getDefaultToolkit() method of the Toolkit class. On my Windows XP system, it is sun.awt.windows.WToolkit.
For homework, please execute this program in the Ariel lab and make a
note of the output. We’ll discuss this
in class on Wednesday.
Mar 12: I’d
like to follow up on something discussed near the end of class today. We expected the following code…
Calendar
c = Calendar.getInstance();
Date
d = ((GregorianCalendar)c).getGregorianChange();
IO.println(d);
to generate a run-time error, but it didn’t. Why? I didn’t have an
answer in class, but I do now. Here it
is. First, note that getGregorianChange() is a method of the GregorianCalendar class, not of the Calendar class. In the code segment above, it appears that no GregorianCalendar object is created. The cast in the second line changes c into a GregorianCalendar reference, thus no compile error is
generated, but the cast does not change memory: the object is still a Calendar object, or so it seems. So, a run-time error should occur in
attempting to execute a GregorianCalendar method on the Calendar object. Right? Wrong! In fact, c is a reference to a GregorianCalendar object. The API for the getInstance() method states that it “gets a calendar using the default time zone and
locale. The Calendar returned is based on the current time in the default time
zone with the default locale.” So, it
seems that the object created (on my computer at York University) is probably a
GregorianCalendar
object. This can be checked by adding
the following line of code:
IO.println(“Class
of c: “ + c.getClass());
Indeed, the class of c is identified as GregorianCalendar.
Whew!
I’ll do a quick demo of this in class next week. See you on Sunday, and good luck.
Mar 10: Here
are the lecture notes for Chapter 9: chapter09.pdf
as well as the demo programs and files used for Chapter 9: DemoInstanceof.java | creditcards2.txt
| DemoToolkit.java | DemoCalendar.java
| DemoRectangle.java
Mar 5: Here are
the lecture notes for Chapter 8: chapter08.pdf as
well as the demo programs and files used for Chapter 8 DemoPortfolio.java | portfolio.txt
| DemoGlobalCredit.java | creditcards.txt
Mar 3: Model
answers to Test #1 are posted on red as /cs/home/wildes/1020/T1W2004/t1.txt.
To view the answers, log on to red.cs.yorku.ca and issue the command
more
/cs/home/wildes/1020/T1W2004/t1.txt
Mar 2: Marks
for Test #1 now posted. Marks are
posted using the department’s courseInfo service. To view your mark,
logon and issue the command courseInfo 1020M
Mar 1: Here
is the source code for the demo program presented in class today: DemoPortfolio.java. At the end of the source code, there is a programming
challenge. Please modify the program,
as requested. We’ll discuss the
solution in class on Wednesday.
Feb 27: The
slides for Chapter 7 (chapter07.pdf) and the ASCII
code chart (ascii.gif) have been updated, as per our
discussion in class today. Please
update your files accordingly.
Feb 25: Here
are the lecture notes for Chapter 7: chapter07.pdf
as well as the demo programs used for Chapter 7: DemoStringArray.java
| DemoEncrypt.java | DemoDecrypt.java
| sample.txt
Feb 25: There
was a fair bit of discussion in class today about ASCII codes. As I noted, ASCII is a 7-bit coding system
for representing alphanumeric symbols, digits, punctuation symbols, and control
codes. ASCII codes appear as the first
128 entries in the 16-bit Unicode coding system. Click here for an image showing the
complete ASCII code chart. We’ll
discuss this in class on Friday.
Feb 24: Note:
The course evaluation for section M will take place Wednesday, March 31,
11:05 a.m.
Feb 13: Here
are the lecture notes for Chapter 6: chapter06.pdf
as well as the demo programs presented for Chapter 6: CharFreq.java
| Substitute.java | StringBackwards.java
| Palindrome.java | WordsBackward.java
| RegexExample.java
Also, here is the Programming Challenge given in class today:
Programming Challenge.
Rework the StringBackwards programming challenge using the StringBuffer class. Call the new program StringBackwards2.java.
Feb 11: Here
are the programming challenges presented in class today. Please solve these for Friday’s class.
Programming Challenge #1.
Write a program that creates a String object from a sequence of
characters inputted from the keyboard and then creates a new String object
consisting of the characters arranged backwards. Output the new string to the console. Call the program StringBackwards.java.
Programming Challenge #2.
Write a program that inputs a word from the console and then checks to
determine if the word is a palindrome.
Output the result to the console.
Call the program Palindrome.java.
(Note: A palindrome is a word that is the same backwards as forwards;
e.g., “toot”)
Feb 6: Here
are the lecture notes for Chapter 5: chapter05.pdf
as well as the demo programs presented for Chapter 5: Example09.java
| Example10.java | Example11.java
| Example12.java | Example12a.java
| Example12b.java | Example12c.java
| Example12d.java | Example13.java
| Example14.java | Example15.java
| Example16.java | Example17.java
| Example18.java | Example19.java
Jan 26: Here
are the lecture notes for Chapter 4: chapter04.pdf
Jan 23: Here
is the solution to today’s Programming Challenge: Mortgage03.java,
as well as the demo programs presented in today’s class: Example07.java | Example08.java
Jan 22: Please
note: There will be no class next Wednesday (Jan 28). I have an appointment for personal matters
that, unfortunately, cannot be changed.
Jan 21: Here
are the lecture notes for Chapter 3: chapter03.pdf as well as the source files for the demo
programs: Mortgage01.java | Mortgage02.java | Example01.java
| Example02.java | Example03.java
| Example04.java | Example05.java
| Example06.java.
Please remember to work on the “Programming Challenge” given in class
today. The problem description is in
the last slide in the notes for Chapter 3.
We’ll take up the solution on Friday.
Jan 16: Here
are the lecture notes for Chapter 2: chapter02.pdf
Jan 12: An
organizational meeting will be held this Thursday for students interested in
the ACM Programming Contest. The
meeting will be at 4:00 pm in CSB 3033.
More information is available from http://www.cs.yorku.ca/acm/.
Jan 9: Here
are the lecture notes for Chapter 1: chapter01.pdf
Jan 7: Please
make sure you purchase the course text as soon as possible. Read chapter 1 immediately, and try to read
chapter 2 before next week.
Dec 10: Announcements
for Section M will be placed here.