DOC PREVIEW
USF CS 112 - Building Larger Programs

This preview shows page 1-2-3 out of 9 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 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 9 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 9 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

{small lecturenumber - heblocknumber :} Announcementsaddtocounter {blocknumber}{1}{small lecturenumber - heblocknumber :} Academic Honestyaddtocounter {blocknumber}{1}{small lecturenumber - heblocknumber :} Academic Honestyaddtocounter {blocknumber}{1}{small lecturenumber - heblocknumber :} Random Numbersaddtocounter {blocknumber}{1}{small lecturenumber - heblocknumber :} Random Numbersaddtocounter {blocknumber}{1}{small lecturenumber - heblocknumber :} Pseudo-Random Numbersaddtocounter {blocknumber}{1}{small lecturenumber - heblocknumber :} Pseudo-Random Numbersaddtocounter {blocknumber}{1}{small lecturenumber - heblocknumber :} Example!addtocounter {blocknumber}{1}Intro to Computer Science IICS112-2012S-07Building Larger ProgramsDavid GallesDepartment of Computer ScienceUniversity of San Francisco07-0: AnnouncementsLabs 1 and 2 to be returned today, see me if youhave any questionsLate policy shift, starting with Project 1: 50%reduction until 24 hours after due dateStyle requirementAcademic HonestyWhat is allowed?What is not allowed?07-1: Academic HonestyWhat is allowed: You may talk with other studentsabout:Generic Java: how classes work, how controlstructures (while/for/if/etc) work, etcAnything covered in class, in the textbook, etc.Assignment requirements: What your codeshould do, what input/output should be, etc.High Level algorithms (Example: inserting intosorted array)07-2: Academic HonestyWhat not allowed:You may not look an another student’s codeYou may not copy another student’s codeYou may not copy code from the web / anyother source and submit it as your own work07-3: Random NumbersWhat if we wanted random numbers (for a dicegame, for example)import java.util.Random;class Test{public static void main(String[] args){Random r = new Random();int randnum = r.nextInt(25);}}r.nextInt(25) returns a value between 0 and 2407-4: Random NumbersThere are no “real” random numbers in JavaComputers are deterministic!That is, they work the same way on the samedata, every time – the output is determined bythe input.Java uses Pseudo-Random numbers insteadNot “really” random, but “look” random07-5: Pseudo-Random NumbersCreate a sequence of numbers that “look random”Bounce all over the number lineStart with a “seed”, initial numberFunction that takes previous number, return thenext one in the sequenceXi= (aXn+ c) mod m07-6: Pseudo-Random NumbersWe can “seed” the Random constructor, by givingthe first element in the sequenceRun the program twice, the same exact seqence ofrandom numbers will occur, great for debuggingIf we don’t give the Random constructor a seed,picks number of miliseconds that have elapsedsince Jan 1, 197007-7: Example!User rolls two dice up to three times to try to beat arandomly generated targetAfter each roll, user decides to roll again or stickwith current rollDriver - mainGame - play //main logicPlayer - all input/outputDie - 6 sided


View Full Document

USF CS 112 - Building Larger Programs

Documents in this Course
Structs

Structs

4 pages

Trees

Trees

25 pages

Strings

Strings

27 pages

Queues

Queues

3 pages

Trees

Trees

24 pages

Arrays

Arrays

5 pages

ArrayList

ArrayList

24 pages

Stacks

Stacks

2 pages

Stacks

Stacks

8 pages

Trees

Trees

24 pages

Stacks

Stacks

8 pages

Queues

Queues

16 pages

Queues

Queues

17 pages

Queues

Queues

17 pages

Load more
Download Building Larger Programs
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 Building Larger Programs 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 Building Larger Programs 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?