a high flying overview cs139 fall 2006 how far we have come
DESCRIPTION
Algorithm A step by step process for solving a problem in a finite amount of time given a finite amount of data.TRANSCRIPT
![Page 1: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/1.jpg)
A High Flying OverviewA High Flying Overview
CS139 – Fall 2006 CS139 – Fall 2006 How far we have comeHow far we have come
![Page 2: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/2.jpg)
We started with the notion of an We started with the notion of an algorithmalgorithm
![Page 3: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/3.jpg)
AlgorithmAlgorithm
• A step by step process for solving a problem in a finite amount of time given a finite amount of data.
![Page 4: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/4.jpg)
Good algorithmsGood algorithms• Require thought – and reading all of the words• And are:
– Simple– Precise– Correct– Complete– Have levels of abstraction
![Page 5: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/5.jpg)
Algorithm structuresAlgorithm structures
• Sequencing• Decisions• Loops• Abstraction (separate procedures)
![Page 6: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/6.jpg)
We learned about our lab We learned about our lab environmentenvironment
stu – Linux?
Lab 250
Lab 248
Novell – n-drivem-drive???
mount-n
submit
![Page 7: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/7.jpg)
We made containersWe made containers
And learned that there were different kinds that held different data
numbers
letters
Strings (why is thiscapital?)
simple (value)
complex (several values)
Variable
Constant
literal
![Page 8: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/8.jpg)
And performed operations on themAnd performed operations on them
addition
assignment
subtraction
multiplication
![Page 9: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/9.jpg)
And then we were ready to build And then we were ready to build our first programour first program
public class Hello{
public static void main(String args[]) {
System.out.println(“Hello World”);}
} But what does it mean???
![Page 10: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/10.jpg)
![Page 11: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/11.jpg)
But that was just the startBut that was just the start
• Containers became variable, literals, and constants
• Operations became expressions• Our programs began to really do
something.• Remember me? TripCalculator.java
![Page 12: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/12.jpg)
Of course that is when we also Of course that is when we also learned aboutlearned about
• documentation• and the dreaded submit• and of course we had to relearn division• 3 / 6 is not .5• 3 % 6 is not something to do with percentages.• compile time errors• run time errors• logic errors
![Page 13: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/13.jpg)
We got to know and love ScannerWe got to know and love Scanner
• and output• and printf (%s, %f, %d, %c)
![Page 14: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/14.jpg)
Then we added decisionsThen we added decisionsif(boolean expression) else
{ }
JMmooDairyBar.java:56: 'else' without 'if'
switch & case
break;
&&, ||, ==
and new error messagesand new error messages
![Page 15: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/15.jpg)
And yes, the JMooDairy Bar
![Page 16: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/16.jpg)
Then came abstractionThen came abstraction
• We learned that we can break code up and refer to a segment of code by a single name.
• Functions provided a way to reuse code; write once use any number of times.
• We also learned that we can create an application with multiple classes.
• Qualified names let us link all of these pieces together.
![Page 17: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/17.jpg)
We also began to explore object We also began to explore object oriented programmingoriented programming
• We began to use “classes” in a more purposeful way.
• We began to look at the “services” provided by java classes.– Scanner– System.out– Random– Math
![Page 18: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/18.jpg)
variable = new ObjectName()variable = new ObjectName()
Scanner(System.in)keyboard =
constructor
instantiation
new
![Page 19: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/19.jpg)
Passing 5 to the Passing 5 to the displayValuedisplayValue MethodMethod
displayValue(5);
public static void displayValue(int num){
System.out.println(“The value is “ + num);
}
The argument 5 is copied into the parameter variable num.
The method will display The value is 5
![Page 20: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/20.jpg)
And of courseAnd of course
• we had a PA to go along with functions
• Conversions.java
![Page 21: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/21.jpg)
and we learned lots of new and we learned lots of new termsterms
parameterargument
visibility modifyer
static
qualified namereturn statement
return type
![Page 22: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/22.jpg)
On to the last of our On to the last of our “procedural” structures“procedural” structures
• But of course not least…bring on the loops.
infinite loop
loop control variableoff by one error
4
pre
post
for
do/while
while
![Page 23: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/23.jpg)
And yet another PAAnd yet another PA
![Page 24: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/24.jpg)
and Starsand Stars
****
************
*************************
**********************************************
* ** *** **** ***** ****** ******* ******** *******************
![Page 25: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/25.jpg)
ObjectsObjects
• class – blueprint• object – specific house
![Page 26: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/26.jpg)
and more termsand more terms
• members• attribute• method• visibility modifiers
again• this• static
• instantiation• constructor• overloading• mutator• accessor• immutable• mutable
![Page 27: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/27.jpg)
We learned to hand trace We learned to hand trace methods and objectsmethods and objects
• Back to containers on a desk.• Each container holds its current value.• We must change the value as it changes
during program execution• Each container must be identified with its
scope.• And about scope….
![Page 28: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/28.jpg)
block scopeblock scope
• inside {}• local - inside method { }• global – inside class { }
• visibility is controlled by the scope of declaration
![Page 29: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/29.jpg)
And even further “scope”And even further “scope”
• static – belongs to the class• non-static – belongs to individual objects
of the class
• static = 1 container• non-static = 1 container per object
![Page 30: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/30.jpg)
And another paAnd another pa
![Page 31: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/31.jpg)
and finally arraysand finally arrays
• subscripted variable• reference type• arr1[3]• elements are individual elements of array
type.• loops – for each loop• index
![Page 32: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/32.jpg)
and the last paand the last pa
![Page 33: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/33.jpg)
Think about how far we have Think about how far we have comecome
• And how much you have learned.• What was hard is now easy.• What is now hard will continue to be easy.
• Preview of 239
![Page 34: A High Flying Overview CS139 Fall 2006 How far we have come](https://reader035.vdocuments.site/reader035/viewer/2022062906/5a4d1b6e7f8b9ab0599b4829/html5/thumbnails/34.jpg)
Next SemesterNext Semester
• Objects and objects• Inheritance• Input and output• Exceptions• Enumerated Types• Polymorphism• Abstract Classes• Interfaces• Recursion• and much much more…