Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD,...

37
Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used for any other purpose without the written permission of Walter Savitch.
  • date post

    21-Dec-2015
  • Category

    Documents

  • view

    216
  • download

    0

Transcript of Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD,...

Page 1: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

Copywrite 2003 Walter Savitch

These slides are for the exclusive use of students in CSE 11 at UCSD,

Winter quarter 2003.They may not be copied or used for

any other purpose without the written permission of Walter Savitch.

Page 2: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

CSE 11

Walter Savitch

3620 APM

Page 3: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

• CSE 11 = CSE 8A + CSE 8B

• You do not need to know any Java to take this course, BUT

• If you have not programmed before in some language, you should not take this course.

• You do Chapters 1-3 of Savitch text on your own. It should be close to a “a review.”

Page 4: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

Text Book

• Savitch, “Java: An Introduction to Computer Science and Programming,” Second Edition.

• Some UNIX book of your choice. (A suggestion is on the handout.)

Page 5: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

• Get Handout and READ IT!

• You must have a computer account for this course. (It starts cs11w__)

• All Home Work graded in interviews.

• All interview in SUNPAL lab APM 3414.

• Teams; HW 1 work alone. All other HW can work in teams of 2.

Page 6: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

Home Work Deadlines

• Two deadlines: turnin deadline, interview deadline.

• If you miss the turnin deadline, you get zero for the assignment.

• If you miss the interview deadline by one or two days, you pay a penalty.

• If you miss the interview deadline by more than two days, you get zero.

Page 7: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

No Work Accepted Late for Any Reason

• Except as already noted for interviews.

• Read the handout.

Page 8: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

Home Work 1

• Is on the handout.• If you do not pass HW 1 by the deadlines,

you must drop the course. No exceptions.• If you take an interview before the turnin

deadline, you do not need to turn in the assignment.

• Instructions for turning in assignments will be given in a later lecture.

Page 9: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

Home Work 1 Deadlines Correction

• Turnin deadline Friday January 17.• Interview deadline Tuesday January 21.• There is a mistake in the deadlines on the

handout.• Home work 2 deadlines will be immediately

after HW 1 deadline. The HW2 turnin deadline may be BEFORE the HW1 interview deadline.

Page 10: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

Proctor Hours

• In public directory

• On website

• APPROXIMATELY: M-Th 9AM-10PMF 10Am-6PMSa noon-6pm

Page 11: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

Quizzes

• Surprise quizzes at end of some lectures.

• Do not ask “Will there be a quiz today?”

• Cannot makeup a missed quiz for any reason.

Page 12: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

Read the Handout

• Cheating policy.

• Meaning of turnin deadlines.

• Grading policy.

• No late work policy.

Page 13: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

Home Computer

• You do not need a home computer.

• If you work on a home computer, you must somehow move your files to the SUNPAL lab for turnin and interviews.

• Java for your home computer is free on Sun website. See Savitch book preface. Get version 1.4 or higher. (1.2 is good enough.)

Page 14: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

UNIX

• We will use the UNIX operating system in the SUNPAL laboratory for all interviews.

• Your programs must be on the SUNPAL machine and must compile and run there.

• You need to know enough UNIX to manipulate files, edit files, compile and run your programs.

• No UNIX on any quiz or exam. Only test of UNIX is that you can do the interviews in the SUNPAL lab.

Page 15: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

Editor

• You can use any editor you wish in the SUNPAL lab, so long as the proctor can give you an interview.

Page 16: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

UNIX commands

• Learn command line commands.

• More details in discussion section.

Page 17: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

UNIX Commands

• cp file1 file2

• cp file1 directory

• mv file1 file2

• rm file

Page 18: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

Wildcards

• cp * directory

• cp *.java directory

Page 19: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

Directories

• Often called folders• mkdir directoryName• cd subdirectoryName• cd ..• cd ~• Learn about absolute and relative path names.

Page 20: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

Java

• General purpose programming language.

• Includes GUI (Graphical User Interface) libraries.

• Includes lots of other libraries.

• Has Internet stuff, but we will use little of it directly.

Page 21: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

Java, What’s Unique?

• Byte Code Compile a Java program, such as MyProg.java, to byte code, MyProg.class.

• Interpret byte code using Java Virtual Machine.

• All but the Java Virtual Machine is portable. Same Java program and same byte code runs on any computer.

Page 22: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

Java, What’s Unique?

• Lots of libraries.

• Threads: multiple processes (not covered in this class.)

• Applets (Covered but no big deal)

Page 23: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

Object Oriented ProgrammingOOP

• The accepted way to program now. To you, “programming” and “object oriented programming” mean the same thing.

• Explained in detail after you know more, but more or less everything you are learning is OOP.

• Java is an OOP language. So is C++. C is not. If the language has classes it is an OOP language.

Page 24: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

Chapters 1-3

• Expressions, similar to most all other languages. int n = 5*(count + 7); //Assignment

• Flow of control. Same as C++; similar to other languages.

Page 25: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

Java Types

• Primitive types: int, double, boolean, char, others.

• Class types, String and others including all the things that you define in Java.

Page 26: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

boolean

• Is a full fledged type in Java.

• Values are not and do not convert to integers. Values are true and false. true is not 1, false is not 0.

Page 27: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

Spelling Conventions

• Class names start with an uppercase, for example, String.

• Variable (and most other things) start with a lowercase, for example, theTime, rate, myStuff, yourStuff.

• Constants (literals) all uppercse, for example, NUMBER_OF_PEOPLE

Page 28: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

Spelling Conventions

• Do not abbreviate use myFirstScore not myFrSc use timeLimit not tmLim nor tmLimit

Page 29: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

Console Output

int number = 7;

System.out.println(number + “ things”);

Screen output:

7 things

Page 30: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

Console Input

System.out.println(“Enter an integer:”);

int number = SavitchIn.readLineInt();

Sets the value of number to the integer types in at the keyboard.

The integer must be on a line by iteslf.

Page 31: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

SavitchIn.readLineInt()

• SavitchIn is a class.

• readLineInt is a method.

• () indicates no arguments.

• Returns a value of type int, namely the integer entered at keyboard.

• Good error messages if user screws up.

Page 32: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

SavitchIn

• A class written in Java.• Is not a standard Java library class.• The file SavitchIn.java (or SavitchIn.class)

must be in the same directory as your program.

• File SavitchIn.java is with programs on machine in SUNPAL and is on CD in the Savitch text.

Page 33: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

SavitchIn

• readLineInt()

• readLineDouble()

• readLineNonWhiteChar()

• readLine()

Page 34: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

readLineNonWhiteChar()

• Different from other methods• Reads the first nonwhite char on a line and

discards the rest of the line.• The char need not be the only thing on the

line.• If line is

yesit reads the ‘y’

Page 35: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

• Next time start Chapter 4

• Get a course account before you leave today.

Page 36: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

public class FirstProgram{ public static void main(String[] args) { System.out.println("Hello out there."); char answerLetter; answerLetter = SavitchIn.readLineNonwhiteChar(); if (answerLetter == 'y') System.out.println("Nice weather."); System.out.println("Good-bye."); }}

Page 37: Copywrite 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter 2003. They may not be copied or used.

public class NameOfProgram

{

public static void main(String[] args)

{

Your Code Goes Here.

}

}