CSC 211 Java I

Download Report

Transcript CSC 211 Java I

CSC 211 Java I
Algorithmic thinking
Today’s plan

Administrivia

Roster
 Course web site





Create a simple program
 Compile and run
Syllabus
Course tools





Each other
Classroom presenter (next
week)
Tablets
OWL
BlueJ
What is an algorithm?
Your first cup of Java



Using BlueJ
Using TextPad
Deliverables

Your algorithm
 Several drawings
 Your first program
 All in a Word file
Basic links
Class web site - https://col.cdm.depaul.edu
(CampusConnect userID and password)
 Textbook – “Java Programming: From
Problem Analysis to Program Design” (3rd
Edition), by D.S. Malik along with OWL
 Syllabus

http://facweb.cs.depaul.edu/asettle/csc211tablet/
info/syllabus.htm
Today’s plan

Administrivia

Roster
 Course web site





Create a simple program
 Compile and run
Syllabus
Course tools





Each other
Tablets
BlueJ
OWL
Classroom presenter (next
week)
What is an algorithm?
Your first cup of Java



Using BlueJ
Using TextPad
Deliverables

Your algorithm
 Several drawings
 Your first program
 All in a Word file
Introductions
Name
 Major (including grad or undergrad)
 Previous programming experience (if any)
 Something everyone should know about
you

Course tools
Each other (no kidding!)
 Classroom Presenter (introduced next week)
 Tablets
 Flash drive
 OWL
 Java 6 JDK/SDK
 BlueJ (or another IDE)

Exercises
Meant to help you understand the
concepts as they are presented to you
 You must work with another classmate

 There
are not enough computers for everyone
in the class
Physically move the chairs so you face
each others and work out a solution
 We will discuss solutions as a group

Group Exercises
Some activities will require larger groups
 You must work with your daily partner and
another pair of classmates
 Physically move the chairs so you face
each others and work out a solution
 We will discuss solutions as a group

Who’s with me?






Instructor side: A check on how well students in the
class have understood a point
Student side: A check on how many in the class share
your understanding of a point
A questions will be posted on the PPT or white board
In Classroom Presenter you need to enter your
answer (multiple choice, text, hand drawing)
Instructor will show one or more answers to the class
We will learn how to do this starting next week
Meeting point
The lab exercises contain several selfpaced activities meant to help you
discover the various concepts we present
 When you see a Meeting Point divert your
attention back to the instructor and the rest
of the class
 We will discuss possible solutions together
or go over some lecture material

Tablets policies





Partner up – Identify a partner you will work with
during the class (either ahead of time or when you
arrive at class)
Check in – Before the start of class pick up one
laptop from the cart, unplug it and replace it with
your or your partner’s ID
Clean up – At the end of class copy all files you and
your partner create on your and your partner’s flash
drive and delete them from the laptop
Check out – Return the tablet to the cart slot with
your or your partner’s ID and plug it in
Do this NOW
More about OWL




This online service will be helpful for you to
practice basic syntax as we go through the
material in class
The system gives you exercises to do and offers
immediate feedback
You can go back as many times as you want to
try to complete the exercises
Each week you will have a number of OWL
exercises to complete
More on OWL
To access OWL: http://owl.course.com/
 You will need to use a code that can be
purchased online at the OWL site
 The system will ask you for your email
address and will let you set your password
 Registration on the system will be your
first OWL exercise
 See the Useful Links for a tutorial about
accessing OWL

The JDK/SDK environment



To be able to run Java programs you need the
Java Development Kit (JDK), also called
Software Development Kit (SDK) installed on
your machine
Download JDK 1.6.11 to the C: drive
http://java.sun.com/javase/downloads/index.jsp
You need the full SDK not just the JRE (Java
Runtime Environment)
The JDK/SDK environment
Once you have installed the SDK you may
need to set the PATH and CLASSPATH
(environment) variables
 If you have a Mac OS X jaguar, the SDK
should be installed by default
 See the Useful Links for tutorials on
installing Java and setting environment
variables

From JDK to Java programs
The JDK/SDK contains the essential
elements to use the Java language
 You will need a text editor to write the
Java programs that contain the instruction
to be executed by the machine
 The instructions are validated by the java
compiler (part of the JDK)

IDEs
Many products were created to ease the
interaction of the user with the JDK, they
are called Integrated Development
Environments (IDEs)
 They contain a smart editor and other
tools for debugging, compiling, and
running your program
 The IDE we will primarily use is BlueJ

BlueJ
BlueJ is already installed on the tablets
and all labs in CDM
 BlueJ is available for download at:

http://www.bluej.org/download/download.html

We’ll start using BlueJ in class today
Today’s plan

Administrivia

Roster
 Course web site





Create a simple program
 Compile and run
Syllabus
Course tools





Each other
Classroom presenter (next
week)
Tablets
OWL
BlueJ
What is an algorithm?
Your first cup of Java



Using BlueJ
Using TextPad
Deliverables

Your algorithm
 Several drawings
 Your first program
 All in a Word file
Group Exercise
Complete Part 1 of Lab 1 by:
 Identifying another partner pair to work with and
moving the chairs so you face each other
 For this exercises you need to select:




Following the instructions in the CSC211_L1.doc
handout



One note taker
One time keeper
One “compiler” who needs to leave the room
I will call time for the various parts as we go
Be prepared to discuss your solution with the rest of
the class
Finish Part 1 of Lab 1 by cutting and pasting your
algorithm and the resulting drawing into your
documents
Group Exercise – My dream
house
Algorithms and Java programs



An algorithm is a set of precise instructions
intended to solve a specific problem
A computer program is an algorithm written in a
“language” that a computer can understand and
execute
The Java language specifies the words and
symbols that we can use and a set of rules that
dictate how the words and symbols can be put
together to form a valid statement
Program is a solution to a problem
• Understand the problem
• Break it down
• Come up with a solution
• Consider alternative solutions
You
• Write down all the pieces needed to implement your solution
• Specify how all the pieces interact with one another
(using English or, better, pseudocode, “Jenglish”)
• Translate the set of instructions (algorithm) using a
programming language (Java in our case)
Today’s plan

Administrivia

Roster
 Course web site





Create a simple program
 Compile and run
Syllabus
Course tools





Each other
Classroom presenter (next
week)
Tablets
OWL
BlueJ
What is an algorithm?
Your first cup of Java



Using BlueJ
Using TextPad
Deliverables

Your algorithm
 Several drawings
 Your first program
 All in a Word file
Another lab exercise
Complete Part 2 of Lab 1
 This is a regular exercise to be completed
by you and your partner
 Read the instructions in the file CSC
211_L1.doc that you downloaded from the
COL site

And yet another lab exercise
Now complete Part 3 of Lab 1 with your
partner by:





Opening the project Picture from the Week 1
materials you downloaded from COL
Compiling the PictureDriver.java class
Right-clicking on the compiled class
Calling the kick-off method: main
Pasting the resulting picture into your document
Processing programs




27
A program must be translated into machine
language before it can be executed on a
particular type of CPU
A compiler is a software tool which translates
source code into a specific target language
Often, that target language is the machine
language for a particular CPU type
The Java approach is somewhat different
The Java compilation process




The Java compiler first translates Java source
code into a special representation called bytecode
The java source code is contained in ordinary text
files, saved with the extension.java
The compiler produces byte code in a .class file
We will learn how to compile (and run) java
programs in two different ways:
 The low-level way, with no IDE
 Using an IDE such as BlueJ
28
Java Translation and Execution





29
Java byte code is not the machine language for any
traditional CPU
It is language for the so called Java Virtual Machine
Another software tool, called an interpreter, makes the
JVM talk to specific processors, translating bytecode
into machine language and executing it
Therefore the Java compiler is not tied to any
particular machine
Java is considered to be architecture-neutral
Java Translation and Execution
PictureDriver.java
Java source
code
Java
compiler
Java
PictureDriver.class
bytecode
Java
interpreter
Machine
code
30
Execution
The final lab exercise
Complete Part 4 of Lab 1 with your partner
by:





Determining how to modify the previous picture
Changing the algorithm to include the new
element
Modifying the PictureDriver class to include
statements implementing your algorithm
Pasting the code you added into your document
Pasting the resulting picture into your document
Today’s plan

Administrivia

Roster
 Course web site





Create a simple program
 Compile and run
Syllabus
Course tools





Each other
Classroom presenter (next
week)
Tablets
OWL
BlueJ
What is an algorithm?
Your first cup of Java



Using BlueJ
Using TextPad
Deliverables

Your algorithm
 Several drawings
 Your first program
 All in a Word file
Submitting the lab

Put you and your partner’s name at the top
of the lab document
 Each
person should keep a copy of the
document

Upload the .docx file to Assignments/Lab 1
on the COL site
 Only
this
one of you and your partner should do