Unformatted text preview:

lOMoARcPSD 14265820 CMSC131 Lecture notes All CMSC131 Lecture notes All Object Oriented Programming I University of Maryland Object Oriented Programming I University of Maryland StuDocu is not sponsored or endorsed by any college or university StuDocu is not sponsored or endorsed by any college or university Downloaded by William Rabalais wrabalais isa nl lOMoARcPSD 14265820 html color codes info colors from image www manning com books generative art http codingbat com java Definitions independent of language 1 Algorithm is the idea expressed by a program and is a generalized idea of a program 2 A program is a sequence of clear instructions in an artificial programming language 3 Different Programming Languages a Artificial designed for a purpose b Evolving changing over time c Equivalent all general purpose languages can perform the same computations 5 A computer is a general purpose programmable machine that processes or manipulates 4 Computing in Process a Data types how to write data values b Variables how to store retrieve data c Expressions how to calculate data Integer Data Type for integers 6 7 Float Data Type for floating point values a Fixed 12 34 10 b Scientific Notation 10e12 1 3e 4 c Explicitly Typed 12 3f 10f 8 Sequential Processing processed one line at a time and processed in order first to last 9 Von Neumann Machine a Four parts Input to Processor to both Output and Memory b Four Concepts Sequential processing stored program binary circuits electrical power c Java Processing Commands are all either i ii iii Input Data from input to memory Assignments data from memory to memory Outputs data from memory to output 10 Variable we can declare a variable by first putting its type then name separated by a space and ending with a semicolon 11 What makes a good program a Good comments Efficient Organized Easy to use Functionality b A program is correct if it matches the specifications It is readable if it communicates well to a reader and efficient if it is shorter faster 12 What s a boolean expression a Values True or False b Operators or II and not c Variables boolean isHappy True 13 Case Analysis table of cases and actions Cases do not overlap mutually exclusive 14 CPU central processing unit brains of the computer Downloaded by William Rabalais wrabalais isa nl lOMoARcPSD 14265820 15 ROM read only memory hold bootstrapping code in a form of firmware 16 Hard Disk example is hard drive files are all stored here 17 RAM random access memory way fast than disk variables are stored here 18 Cache there are little levels a L1 is the fastest and smallest b L2 slower than 1 but faster than 3 c L3 largest and slowest 19 Operating System system software that makes computer do work Interface between programs and hardware 20 Applications software you install in your operating system 21 Gregory s Series 22 Iteration mechanism of repetition 23 Conditional Processing while there s more data get some if it meets a condition process it 24 Integer Division a a b is 3 when a 10 and b 3 b a b is 1 i is mod function remainder 25 Methods vs Call a Call needs a header tells you what goes in and what goes out b Method e x println sqr 4 Examples cube x x 3 sigmoid x 1 1 e x i Writing own Method 1 header 2 body 3 ii Writing own method float cube float x return x x x float abs float x if x 0 return x else return x OR OR float max2 float x float y if x y return x else return y c Call e x println 2 sqr 2018 d e Variable Parameter can be constant float y sqr PI 4 26 Whats void Means no return statement method prints draws Downloaded by William Rabalais wrabalais isa nl lOMoARcPSD 14265820 27 Static and Dynamic Mode a Static no definitions e x what goes into void setup b Dynamic method definitions e x is void 28 A local variable is valid only in the block which it is declared 29 Series is a continuing sum of sequence of terms 30 General Structure for Method type method name parameters a statements b return 31 Arrays instead of one variable and one value one variable and multiple locations a type name new type memory b Array Operations does A equal B copy A and B sum product 32 Naming Conventions a i j k used as indices b n m used as length 33 Geometric mean is to average as factorial is to sum 34 Search how to find an array if it contains a known key 35 Documenting Your Code 1 2 Lab NAME OF LAB S Gessner Month Day Year Commands fill c set fill color R G B transparency 1 point x y line x y x2 y2 2 rect x y w h 3 4 triangle x y x2 y2 x3 y3 5 quad x y x2 y2 x3 y3 x4 y4 6 ellipse x y w h 7 arc x y w h start stop 8 9 noFill set transparent fill 10 stroke c set stroke color 11 noStroke set transparent stroke 12 keyPressed 13 void draw 14 void setup 15 float x random 16 float y random 17 strokeWeight 18 frameRate slows down or speeds up The bigger the faster 19 To create a variable a Int x 0 the width begins at 0 Downloaded by William Rabalais wrabalais isa nl lOMoARcPSD 14265820 b Or to increase by 20 X x 20 20 void keyPressed Is an event happens when key is pressed a If key s i b println key saveFrame pic jpg 21 Pic jpg double quotes multiple symbols 22 println int key a cast converts types 23 if key Use if to turn off stroke change fill color change stroke color etc a Or if boolean expression statement i if x width b c Or if boolean expression i ii iii statement1 Else statement2 d 24 void mouseDragged happens when mouse is moved and dragged 25 Equal is not equal is less than equal is greater than equal 26 abs x absolute value 27 Practice 1 Writing if Statements 1 y I x I if x 0 a b y x c if x 0 d y x 2 z max x y a if x y b z x if x 0 y x else y x c else d z y r b sqroot b 2 4ac all of 2a 1 2 d sqroot b 2 4ac 1 Give grades A 90 B 80 C else a D sqrt b b 4 a c b c if d 0 r1 b a if score 90 b grade A c else if score 80 d grade B e else Downloaded by William Rabalais wrabalais isa nl lOMoARcPSD 14265820 f grade C 2 For loop a For init test increment b statement i 3 double factorial or variable i is literally just i i 1 a Makes more decimals precision 4 To get 1 sqroot 2pi e x 2 …


View Full Document

UMD CMSC 131 - Lecture Notes

Documents in this Course
Set #3

Set #3

7 pages

Exam #1

Exam #1

6 pages

Exam #1

Exam #1

6 pages

Notes

Notes

124 pages

Notes

Notes

124 pages

Load more
Download Lecture Notes
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 Lecture Notes 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 Lecture Notes 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?