CS 170
Java Programming 1
Welcome to CS 170
All about CS 170
The CS 170 Online Materials Java Mechanics: Your First Program
What’s the Plan?
Topic I: What’s CS 170 All About?
Contact information
Topics, Goals and Objectives Exams and Assignments
Textbook and software Rules for the course
Topic 2: the online classroom, lessons and assignments Topic 3: Java Mechanics
Learn to use the DrJava Development Environment Enter, modify and run three kinds of Java programs
Contact Information
The syllabus is always available from my Web site:
http://faculty.orangecoastcollege.edu/sgilbert
Here’s how you can contact me:
Clark Computing Center, Office F
Office hours: M: 1:15-2:15, T: 3:15-5:15 , W: 10-11
Email: StephenGilbert@gmail.com, sgilbert@occ.cccd.edu Phone: (714) 432-0202 ext 21173
What’s CS 170 About?
First programming class for Computer Science majors
Intended as a transfer class to 4-year college
SMART-ICS agreement with UCI, CSU Fullerton
Meets computing requirement at some universities
Principles of programming, using Java as the language
Learn to write your own computer programs This semester we'll also be processing media A lot of work, but a lot of fun if you get into it
Are You Ready?
While there are no subject prerequisites for this course,
I assume that you are computer literate
Install and run programs
“Move around” your computer’s file system (copy, delete) Use a zip/unzip program to work with archives
Create and save plain text files
Use the Web and email (upload, download, etc.)
Course Goals
If you successfully complete this class you'll:
Understand and explain principles of OO Programming
Prepare you for other modern languages
Use different kinds of program development tools
Write applications and applets using the fundamental
packages in the Java platform
Won't study all the classes; try to master a few
Learn how to use the Java documentation so it can teach
How Can You Succeed in CS 170?
Don't need to be a "brain" but must put in quality time
Like a marathon or getting in shape
Anyone can do it, but you have to keep at it
2.5 hours on-campus and about 12 hours outside
Includes 2.5 hours online lessons, 8 hours practice
Cramming won't help you at all; highly sequential material Practice, practice, practice
How Will You Be Graded in CS 170?
2 Exams: 1 midterm (15%.), 1 final (25%)Multiple-choice: 1-2 hrs closed book, online
10 Reading Quizzes: (7.5%) – online, open book
10 Programming Quizzes: (35%) – in-class, closed book
Hands-on proficiency demonstrations, some re-do
Weekly "labs" or "In-Class" exercises (7%)
Weekly Homework: practice for exams (15%)
1045 points, grade on 1000 (45 extra for emergencies)
Textbook
Introduction to Java Programming
Custom textbook for CS 170
Tony Gaddis-ISBN: 9780558618063 Available in the OCC bookstore ($75)
Includes 7 chapters from the 4th edition Starting Out With Java:
From Control Structures through Objects
ISBN: 978-0136080206.
Software and Supplies
Software is all free and cross-platform
At home, you can use Windows, Unix/Linux, Mac OS X Use Java version 6 (may use 5 on older Macs (10.4)) An OCC-customized version of DrJava IDE
Can put everything on a USB thumb drive
Then you can work on almost any computer
Rules for the Course
May take Pass/Fail; request deadline on your schedule No late work accepted
Assignments normally due by noon on Monday
45 points possible extra credit to cover "emergencies" Don't wait until the last minute
Retry/makeup only for programming proficiency quizzes
May re-try up to 4 of the 10 PPQ exams
Pay attention to OCC drop deadlines: no Incompletes Do your own work, and act like adults
Topic 2
The CS 170 Online Classroom
Getting Into the Classroom Getting Around the Classroom
Submitting Assignments and Taking Quizzes Reading the Online Lessons
Passwords and Logging In
You'll have two passwords for this classA OCC Computing-Center password for the LAN
See the help-desk in the Computing Center for info
A MyOCC password to get into your email, etc.
Direct Log-on
Can log onto Blackboard directly (no MyOCC)
Still use your MyOCC password and ID
https://cccd.blackboard.com
Probably want to bookmark this
Half of your "class-time" will consist of online "lectures"
Blackboard Tutorials
You'll need to read the online tutorials to learn how to use
CS 170 Classroom
Quizzes
You'll take the reading quizzes online, outside of class
Assignments
Use the Assignment Drop-box to turn in IC assignments
Your "IC" or "Lab" Document
Will submit an "in-class" lab document each week. Use Word or OpenOffice to create a new document
Save the file as IC01.doc (Office 97-2003 compatible) Place on your network U: drive or on a thumb drive Put your name and today's date at the top of the sheet Title it "CS 170 In-class Exercise 1"
Save and close, upload to Blackboard and submit. Exercise 1.1: show me your assignment submitted Retrieve and discard uploaded file when done.
Weekly Lessons
Homework Assignments
Exercise page at bottom of weekly start page
Directions, points, submission instructions Start working on Homework 01 now
Topic 3
Hands-On: Java Mechanics
How are Java programs created? What steps do you follow?
Step 1: Write the Code
Use a text editor to write your programming instructions in the Java language
Notepad, SciTE, vi, TextWrangler or an IDE
We'll use DrJava
Called source code Save in a file with
Step 2: Compile the Code
Use a Java compiler to translate your source code into
executable machine code
javac in the JDK
Called bytecode Stored in a file with
the extension .class If syntax errors occur,
Step 3: Run your Program
Use a Java Virtual Machine (JVM) to load the bytecode,
translate into native machine code and start it running
Applications: java.exe
or javaw.exe
Applets: HTML
Web browser, appletviewer
If runtime errors occur,
Your First Java Program
We'll first write an application using the DrJava IDE
Exercise: copy the cs170home-F10 folder from Q: and
place (drop) it on your U:\ (network) or USB Thumb drive
Starting DrJava
Exercise: start the DrJava IDE by opening the tools
Logging In
Type your last name and student ID to start DrJava.
Student ID must start with C
Skip any spaces in your last name If you aren't registered or are
not connected to the Internet, then select Guest Access
Logging-in is needed to record the score for your homework assignments
Preview: Java Syntax
Every Java program is a class definition
Class definition is a blueprint to construct objects The basic class structure looks like this:
… some stuff
public class SomeClassName {
… some more stuff }
Must be stored in SomeClassName.java Only one public class per file
Step 1: Edit the Source Code
Find source code for program at:Q:\faculty5\sgilbert\cs170\edit-program01.gif Right-click, "Preview" Type in code, replacing noted portions
Save the file
when done
Exercise 1.2
Step 2: Compiling Your Program
Several ways to compile your code when savedRight-click to compile a single file
When Bad Things Happen
Common Syntaxor Compiler Errors
Syntax must be 100% correct for a program to run Capitalization: (System not system, String not string) Spelling the name of your source file incorrectly
Forgetting or mismatching the number of braces Mistaking parentheses for braces
Misspelling the name of a variable
Edit and then recompile until there are no errors
Exercise 1.3
Step 3: Running Your Program
You can use the menu command Tools->Run Document,
Viewing the Output
Program is run in DrJava's Interactions Pane Can view just output in Console Pane
Exercise 1.4
Testing Your Code
Program may not do what you want (logic error) Test by comparing actual and expected output
I'll supply tests for first few weeks. Later you'll learn how to write your own test programs.
Testing Your Code
Check program looks for existing test sets.
Test Results
Results appear in Interactions and Console panes
Exercise 1.5
Check your Style
Portion of your grade based on program style
Fix Style Errors
Checkstyle shows errors in external process pane:
Correct all style errors by checking line number
Exercise 1.6
GUI App and Java Applet
To complete your IC "lab" document:Compile and run a Java GUI application Compile and run a Java applet
Shoot screen-shots Submit to Blackboard
Instructions are in online lesson on Blackboard
Finishing Up
Reading for next week:
Mediacomp: read Chapter 1 and start Chapter 2 Gaddis: start Chapter 1
Homework, Quiz and Assignments
Deadline is Tuesday at noon because of Labor Day Introduce yourself on discussion board
Three homework problems