DOC PREVIEW
Duke CPS 004 - Review for Exam 2

This preview shows page 1-2-3-4-5 out of 16 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 16 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 16 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 16 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 16 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 16 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 16 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CompSci 4Review for Exam 2 Nov 8, 2007Prof. Susan RodgerAnnouncements• Start Java next time– We will use Eclipse with Java• Assignment 6 due tonightTopics for the Exam•No HTML• Alice Chapters 1-2,4-7,9-10– Focus on Chap 5-7, 9-10•Topics– Random numbers– Looping structures –Variables– If/else– Lists/ArraysRandom Numbers• Assume they work– Can use = = to compare integers– Use “integer only” if you want an integer– Use “random number” to generate random numbers• Maximum is “up to but not including”• Default valuesLooping Structures• Loop– Simple and complicated•While• When to use “while” vs. “if”Conditionals – If/Else• Formatif (condition)do if trueelsedo if false•Nested ifs• 3 Logical and 6 relational operators• When do you use an “if” vs “while”Variables• Types– Local variable– Parameter– World variable– Class variable• What do you do with a variable?– It stores a value• Initialize it• Use its value• Update itLists• Create a list• Process a list– For all in order– For all together– Item-in-list• List searchArray• Create an Array• Process an array– Loop – complicated version– Use value from array– Set value in array• Search for item in an arrayHow to Study for the Exam• Write methods from old classworks• Lecture notes• Reading quizzes – will make available• Reading in book• Understand the topicsProblem• Objects are a Bunny and a bunch of frogs. They are all facing the same direction. The Bunny is behind the frogs.• The frogs are all in a list called “frogs”• The Bunny and frogs will be moving each time an event occurs. The bunny will move 0.5 meters and the frogs 0.15 meters each time.• When the Bunny is at least the “Bunny’s depth” in front of all the frogs, it should turn around and say “Stop”Animation•Start•FinishWrite function IsBunnyInFront• Returns true if Bunny is at least Bunny’s depth in front of all the frogs in the list frogs• Else returns falseWrite method moveAndCheck• Moves all the frogs in the list frog 0.15m• Moves the bunny 0.5m• If the bunny is in front of all the frogs, turns around and says


View Full Document

Duke CPS 004 - Review for Exam 2

Documents in this Course
Lecture

Lecture

18 pages

Chapter 7

Chapter 7

18 pages

Chapter 9

Chapter 9

15 pages

Java 1

Java 1

24 pages

Java 3

Java 3

11 pages

Lecture

Lecture

10 pages

Chapter 4

Chapter 4

28 pages

Chap 2

Chap 2

16 pages

Graphics

Graphics

20 pages

Lecture

Lecture

12 pages

HTML

HTML

16 pages

Java 1

Java 1

6 pages

Chapter 4

Chapter 4

16 pages

The Plan

The Plan

25 pages

Lecture

Lecture

16 pages

Chapter 6

Chapter 6

21 pages

Lecture

Lecture

18 pages

Lecture

Lecture

23 pages

Lecture

Lecture

16 pages

Lecture

Lecture

19 pages

Lecture

Lecture

12 pages

Lecture

Lecture

5 pages

Lecture

Lecture

26 pages

Lecture

Lecture

16 pages

Chapter 7

Chapter 7

23 pages

Lecture

Lecture

21 pages

Lecture

Lecture

4 pages

Lecture

Lecture

4 pages

Lecture

Lecture

8 pages

Lecture

Lecture

4 pages

Lecture

Lecture

10 pages

Chapter 4

Chapter 4

32 pages

Java

Java

4 pages

CompSci 4

CompSci 4

18 pages

Lecture

Lecture

26 pages

CompSci 4

CompSci 4

12 pages

HTML

HTML

17 pages

Lecture

Lecture

16 pages

Chapter 5

Chapter 5

22 pages

Lecture

Lecture

4 pages

Chapter 4

Chapter 4

10 pages

Chapter 2

Chapter 2

15 pages

Chapter 8

Chapter 8

14 pages

Lecture

Lecture

15 pages

Load more
Download Review for Exam 2
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Review for Exam 2 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Review for Exam 2 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?