|This course ended|
December 10, 2021
CPSC 124: Introduction to Programming
Department of Mathematics and Computer Science Hobart and William Smith Colleges Spring 2021. Instructor: David J. Eck (firstname.lastname@example.org) Syllabus: http://math.hws.edu/eck/courses/cpsc124_f21.html Monday, Wednesday, Friday, 9:50–10:50 AM Coxe 7. Lab: Tuesday, 10:10–11:40 AM Rosenberg 009.
|Quiz and Test Answers|
|Quiz #1, August 30||Quiz #2, September 6||Quiz #3, September 13|
|Test #1, September 24||Quiz #4, October 4||Quiz #5, October 18|
|Quiz #6, October 25||Test #2, November 1||Quiz #7, November 15|
Some Sample Programs and Lab Solutions
Note that some of the lab solutions are dependent on files that were provided in the labs. Those files are available through the lab web pages that are linked in the table above.
- AdditionQuiz.java, from class on September 8
- two solutions to the Lab 3 Baseball exercise: Baseball.java and BaseballBasic.java
- a solution to the Lab 4 LoopyArt exercise: LoopyArtComplete.java
- Primes10000.java, from class on September 27
- PrimesWithSubroutines.java, a revision of Primes10000, from class on October 4
- CrapsProbability.java, which simulates playing many Craps games, from class on October 6
- a solution to the Lab 6 hangman game: HangmanComplete.java
- a solution to the Lab 7 turtle graphic exercises: TurtleGraphicsComplete.java
- a solution to the Lab 8 arithmetic quiz exercise: ArithmeticQuizComplete.java
- three different solutions to the Lab 8 Brownian motion exercise: BrownianMotionComplete1.java, BrownianMotionComplete2.java, and BrownianMotionComplete3.java
- a solution to the Lab 9 Midi exercises: MidiPlayerComplete.java, Note.java, and Tune.java.
- the completed GUI tutorial from Lab 10: Sketcher.java
- a solution for Labs 12 through 14: HangmanComplete.java (requires WordList.java" and wordlist.txt)
- Programs looked at in class on December 1 (not written in Java): Sorting demo, Conway's Game of Life Demo, and High-speed Life.
Some Useful Links
- Introduction to Programming Using Java, the textbook for the course.
- PDF version of the textbook, good for reading on-screen.
- A Style Guide for Java Programming.
- Some information about Linux.
- If you want to use Java on your own computer:
- Some basic instructions.
- Download Site for OpenJDK, where you can download installers for OpenJDK, for Mac OS or for Windows. Installing an OpenJDK will allow you to compile and run Java programs on the command line on your own computer. OpenJDK 16 is recommended for this course. OpenJDK 11 will also work.
- Download site for JavaFX, which we will use later in the course for GUI programming. To use JavaFX on your own computer, you will need an "SDK" appropriate for your system, probably "JavaFX Windows x64 SDK" for Windows or "JavaFX Mac OS X SDK" for Mac. Unless you are using an older version of Java, you should get the Latest Release (Version number 16).
- Download Site for Eclipse, an integrated development environment for Java programming. We will use Eclipse later in the course. The correct package for this course is "Eclipse IDE for Java Developers." (The "Installer" is NOT recommended.) You need the appropriate version for your operating system.
Final Exam: December 10
The final exam for this course takes place on Friday, December 10, at 8:30 AM in our regular classroom.
A study guide for the exam was handed out in class on December 1.
Fifteenth Week: November 29; December 1 and 3
We will spend the last week of the semester with Chapter 7. We have already covered parts of this chapter, but there are some examples and language features that are new. We will spend the most time on Section 7.4. which covers searching and sorting and introduces the idea of analyzing and comparing the run times of algorithms.
Friday will be mostly devoted to review for the final exam.
Remember that your final project is due this Friday, December 3. I expect to print out your programs Saturday morning.
Fourteenth Week: November 22.
On Monday, I will discuss keyboard events, along with a little more discussion of events in general. After that, we will be moving on to Chapter 7, which is about arrays and ArrayList. We have already covered parts of that chapter. We will spend the rest of the semester covering the rest of it.
There is no class for the rest of the week because of Thanksgiving break. Happy Thanksgiving!
Thirteenth Week: November 15, 17, and 19
We will finish the material from Chapter 5 and will devote the rest of the week to look at selected topics from Chapter 6. Chapter 6 covers GUI programming with JavaFX. We have already done quite a bit of that, in an unofficial sort of way, but now we will be looking at things more abstractly and in more detail. We will not have time to cover everything, so you should pay attention to what is actually covered in class. (And read the whole chapter when you get a chance.)
Twelfth Week: November 8, 10, and 12
We will spend a little more time on Section 5.5. For the rest of the week, we will look at topics from the remainder of Chapter 5. The important topics are the special variables this and super (Section 5.6), basic interfaces (Subsection 5.7.1), and basic nested classes (Subsection 5.8.1 and Subsection 5.8.2). I will also be able to say more about lambda expressions, which we have started using in GUI programs but which I have not really explained.
Eleventh Week: November 1, 3, and 5
There is a test on Monday, November 1. A study guide was handed out in class on Wednesday, October 27.
After the test on Monday, we will spend the rest of the week on Section 5.5, which covers subclasses and inheritance. This is an important aspect of object-oriented programming, and it will take some time to cover it.
Tenth Week: October 25, 27, and 29
There is a quiz this week on Monday, October 25. The second test will be next Monday, November 1.
The reading for the week is Section 5.3 and Section 5.4. The main topic is object-oriented programming. We will look at the Card, Deck, and Hand examples from Section 5.4. We might get into Section 5.5 on Friday, but that section will not be on the test.
Ninth Week: October 18, 20, and 22
We have started Chapter 5, but have not quite finished Section 5.1. We will finish that on Monday and move on to Section 5.2, which covers constructors. By Friday, we should get into Section 5.3 and Section 5.4, which are about using classes and objects, but we will continue with those sections for at least the first part of next week.
There is a quiz on Monday, October 18, covering Chapter 4. There will be another quiz the following Monday and then a test the week after that.
Eighth Week: October 13 and 15
We still have to finish up a bit of Chapter 4. The last three sections of that chapter have information on a lot of topics, and you are not responsible for all of them. You are responsible for the material in the following subsections: 4.6.1, 4.6,2, 4.6.3, 4.6.5, 4.7.1, 4.7.2, 4.8.1, 4.8.3, and 4.8.4. We have already covered a lot of that material.
We will then move on to Chapter 5, which introduces object-oriented programming. You should read Section 5.1, which covers central ideas about objects and their relationship to classes. We might start Section 5.2 on Friday.
There is no lab this week. The work from last week's lab is due next week.
You can expect another quiz next Monday.
Seventh Week: October 4, 6, and 8
There is a quiz at the start of class on Monday of this week.
We are working on Chapter 4, which covers writing subroutines and using them to construct more complex programs. The new reading for the week is Section 4.3, and Section 4.4. Sections 4.2 through 4.4 cover all the basic aspects of writing subroutines, including parameters and return values. Global and local variables are also covered. We will also be discussing how to use subroutines to build complex programs, which covers some of the material from Section 4.6.
Next week is Fall Break. There is no class on Monday and no lab on Tuesday. And there will not be a quiz next week.
Sixth Week: September 27 and 29; October 1
The reading for the week is Section 3.8, Section 4.1, and Section 4.2. Section 3.8 introduces arrays. The lab on Tuesday will be about arrays but, just as important, will introduce the Eclipse IDE (Integrated Development Environment). We will them move on to Chapter 4, which is about writing your own subroutines.
There is no lab work due this week. The work from Labs 5 and 6 will all be due on October 7. And there is no quiz on Monday. However, you can expect another quiz next Monday, October 7.
Fifth Week: September 20, 22, and 24
There is a test this week, on Friday. Click here for a study guide. A copy of the study guide will be handed out in class on Monday.
The reading for the week is Section 3.6
and Section 3.7. In fact, we already
switch statement from Section 3.6 on Friday. Section 3.7 covers
exceptions and the
try..catch statement. Note that none of this material is covered on the test.
We will spend some time on Wednesday reviewing for the test and looking at some sample problems from past tests. It is possible that we will start Section 3.8, if there is time.
Fourth Week: September 13, 15, and 17
We will continue looking at control structures this week. Most important are the for loop and the form of the if statement that uses else if. The break statement, which can be used to exit a loop early, is also important. We will discuss the do..while statement and the switch statement, but they are less important. I will expect you to be able to read and understand code that uses do..while and switch, but I will not require you to use them in code that you write yourself.
The reading for the week is Sections 2 through 5 in Chapter 3. From Section 3.2, the main take-away is the idea of algorithm. (You might want to look at Section 3.9, which talks about JavaFX. The material in that section has been covered in labs, and we won't be spending more time on it in class.)
There is a quiz on Monday this week, and a test coming up at the end of next week, on Friday, September 24.
Third Week: September 6, 8, and 10
The reading for the week is Section 3.1 and Section 2.5. We will start the week on Monday with Section 3.1, which introduces two of Java's control structures: the while loop and the if statement. We will look at a number of examples, and you will start using these control structures in the lab on Tuesday. We will continue with examples on Wednesday, but we will start concentrating on how to go about developing a program to carry out a given task.
Section 2.5 is full of detail about expressions in Java. It covers many different "operators" such as %, >=, &&, ++, and +=. We will cover some of the most important ones in class, but you should read that section for yourself and use it as a reference when needed. (Section 2.6 contains information about using Java. We will not cover it, and it is not required reading. It could be useful to you if you are trying to use Java on your own computer.)
Once again, there is quiz at the start of class on Monday.
Second Week: August 30; September 1 and 3
The reading for the week is Section 2.3 and Section 2.4. You can skip Subsections 2.3.4, Subsection 2.3.5, and Subsection 2.4.4. We will not cover the material in any of those sections. You can also skip Subsection 2.4.6 for now, but we will cover it eventually.
The main topic is using pre-defined subroutines. We will look at some of the subroutines defined in class Math, in class System, and in objects of type String. These are all standard, built-in parts of Java. We will also see how to use input subroutines from TextIO, a class that is not a standard part of Java. Many of the subroutines that we will look at are "functions." That is, they return, or compute, a value. The lab on Tuesday will also introduce subroutines from the GraphicsContext class, which are used to draw shapes on the screen.
There is a quiz on Monday, at the beginning of class, covering Sections 1.1, 1.3, and 2.1.
First Week: August 23, 25, and 27
Welcome to the course!
You should begin reading the textbook, which is available on-line at http://math.hws.edu/javanotes. Because the first lab is on Tuesday, we will move very quickly into the most basic aspects of Java programming, which are covered in Section 2.1 and Section 2.2. Some of the same information that you need will be provided in the lab, and the work for the lab is not due until next week, but it would be useful to start reading Chapter 2.
Aside from starting in on Java programming, during the first week of the semester, we will go over some of the introductory material from Chapter 1 of the textbook. We will cover only a part of Chapter 1 in class, but it is a good idea to read the entire chapter to get a preview of most of the topics that will be covered during the rest of the semester. However, you should not expect to fully understand everything in Chapter 1 at this time. The most important sections are Section 1.1 and Section 1.3. Those two section give a brief overview of how computers and Java actually work. Sections 1.4, 1.5, and 1.6 give short overviews of many of the topics that we will cover in the rest of the semester. It is recommended that you read them to orient yourself in the course, but they are not required reading.
The required reading for the first week also includes the course syllabus!