A High Flying Overview CS139 – Fall 2010 How far we have come.

Slides:



Advertisements
Similar presentations
Programming Languages and Paradigms
Advertisements

INTRODUCTION Chapter 1 1. Java CPSC 1100 University of Tennessee at Chattanooga 2  Difference between Visual Logic & Java  Lots  Visual Logic Flowcharts.
© 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Starting Out with Java: From Control Structures through Objects Fourth.
Written by: Dr. JJ Shepherd
Chapter 7 User-Defined Methods. Chapter Objectives  Understand how methods are used in Java programming  Learn about standard (predefined) methods and.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
Road Map Introduction to object oriented programming. Classes
COMP 14 Introduction to Programming Mr. Joshua Stough February 28, 2005 Monday/Wednesday 11:00-12:15 Peabody Hall 218.
CS 201 Functions Debzani Deb.
Terms and Rules Professor Evan Korth New York University (All rights reserved)
CS 225 Java Review. Java Applications A java application consists of one or more classes –Each class is in a separate file –Use the main class to start.
Fundamental Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
Review Java.
COMP 14: Primitive Data and Objects May 24, 2000 Nick Vallidis.
CS0007: Introduction to Computer Programming Introduction to Arrays.
Introduction to Object Oriented Design. Topics Designing Your Own Classes Attributes and Behaviors Class Diagrams.
METHODS Introduction to Systems Programming - COMP 1005, 1405 Instructor : Behnam Hajian
Writing Classes (Chapter 4)
© The McGraw-Hill Companies, 2006 Chapter 4 Implementing methods.
Modular Programming Chapter Value and Reference Parameters computeSumAve (x, y, sum, mean) ACTUALFORMAL xnum1(input) ynum2(input) sumsum(output)
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
Java ProgrammingtMyn1 Java Programming Timo Mynttinen Mikkeli University of Applied Sciences.
Lecture 2: Classes and Objects, using Scanner and String.
Using Data Within a Program Chapter 2.  Classes  Methods  Statements  Modifiers  Identifiers.
Starting Out with Java: From Control Structures through Objects Fifth Edition by Tony Gaddis Chapter 5: Methods.
C++ / G4MICE Course Session 2 Basic C++ types. Control and Looping Functions in C Function/method signatures and scope.
1 Methods Introduction to Methods Passing Arguments to a Method More About Local Variables Returning a Value from a Method Problem Solving with Methods.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Working With Objects Tonga Institute of Higher Education.
Designing Classes CS239 – Jan 26, Key points from yesterday’s lab  Enumerated types are abstract data types that define a set of values.  They.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 6 Objects and Classes.
By Mr. Muhammad Pervez Akhtar
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 5-1 Why Write Methods? Methods are commonly used to break a problem down.
Methods OR HOW TO MAKE A BIG PROGRAM SEEM SMALLER.
Written by: Dr. JJ Shepherd
Chapter 5 : Methods. Why Write Methods?  Methods are commonly used to break a problem down into small manageable pieces. This is called divide and conquer.
Chapter 5 Methods 1. Motivations Method : groups statements that perform a function.  Level of abstraction (black box)  Code Reuse – no need to reinvent.
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
Expressions Methods if else Statements Loops Potpourri.
A High Flying Overview CS139 – Fall 2006 How far we have come.
Method Examples CS 139 Algorithm Development 10/06/2008.
5.1 Basics of defining and using classes A review of class and object definitions A class is a template or blueprint for an object A class defines.
Mid-Year Review. Coding Problems In general, solve the coding problems by doing it piece by piece. Makes it easier to think about Break parts of code.
Functions in C++ Top Down Design with Functions. Top-down Design Big picture first broken down into smaller pieces.
PROGRAMMING USING PYTHON LANGUAGE ASSIGNMENT 1. INSTALLATION OF RASPBERRY NOOB First prepare the SD card provided in the kit by loading an Operating System.
9.1 CLASS (STATIC) VARIABLES AND METHODS Defining classes is only one aspect of object-oriented programming. The real power of object-oriented programming.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
Information and Computer Sciences University of Hawaii, Manoa
CE221 – Data Structures & Algorithms Lab Introduction
Chapter 7 User-Defined Methods.
Suppose we want to print out the word MISSISSIPPI in big letters.
Object Oriented Programming
Testing and Debugging.
Methods.
CS139 – Fall 2010 How far we have come
Chapter Topics Chapter 5 discusses the following main topics:
Starting Out with Java: From Control Structures through Objects
Group Status Project Status.
Chapter 5: Methods Starting Out with Java: From Control Structures through Objects Third Edition by Tony Gaddis.
Chapter 6 – Methods Topics are:
Starting Out with Java: From Control Structures through Objects
Week 4 Lecture-2 Chapter 6 (Methods).
Chapter 5: Methods Starting Out with Java: From Control Structures through Objects Third Edition by Tony Gaddis.
Chapter 5: Methods Starting Out with Java: From Control Structures through Objects Third Edition by Tony Gaddis.
Loops CGS3416 Spring 2019 Lecture 7.
Review for Midterm 3.
Corresponds with Chapter 5
Chapter 6: Methods CS1: Java Programming Colorado State University
Presentation transcript:

A High Flying Overview CS139 – Fall 2010 How far we have come

We started with the notion of an algorithm

Algorithm A step by step process for solving a problem in a finite amount of time given a finite amount of data. A step by step process for solving a problem in a finite amount of time given a finite amount of data.

Good algorithms Require thought – and reading all of the words Require thought – and reading all of the words And are: And are: Simple Simple Precise Precise Correct Correct Complete Complete Have levels of abstraction Have levels of abstraction

Algorithm structures Sequencing Sequencing Decisions Decisions Loops Loops Abstraction (separate procedures) Abstraction (separate procedures) Abstraction (separate classes) Abstraction (separate classes)

We learned about our lab environment stu – Linux? Lab 250 Lab 248 Novell – n-drive m-drive??? mount-n submit

We made containers And learned that there were different kinds that hold different data numbers letters Strings (why is this capital?) simple (value) complex (several values) Variable Constant literal

And performed operations on them addition assignment subtraction multiplication division

And then we were ready to build our first program public class Hello { public static void main(String args[]) { System.out.println(“Hello World”); }}

But that was just the start Containers became variables, literals, and constants Containers became variables, literals, and constants Operations became expressions Operations became expressions Our programs began to really do something. Our programs began to really do something. Remember me? PA1 (Harrisonburg taxes) Remember me? PA1 (Harrisonburg taxes)

Of course that is when we also learned about documentation documentation and the dreaded submit and the dreaded submit and of course we had to relearn division and of course we had to relearn division 3 / 6 is not.5 3 / 6 is not.5 3 % 6 is not something to do with percentages. 3 % 6 is not something to do with percentages. compile time errors compile time errors run time errors run time errors logic errors logic errors

We got to know and love Scanner // consume the new line // consume the new line More runtime errors More runtime errors and output and output and printf (%s, %f, %d, %c) and printf (%s, %f, %d, %c)

Then we added decisions if(boolean expression) else { } MadLibs.java:56: 'else' without 'if' switch & case break; &&, ||, == and new error messages

And we played with the Stars and Planets

Then came abstraction We learned that we can break code up and refer to a segment of code by a single name. 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. 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. We also learned that we can create an application with multiple classes. Qualified names let us link all of these pieces together. Qualified names let us link all of these pieces together.

We also began to explore object oriented programming We began to use “classes” in a more purposeful way. We began to use “classes” in a more purposeful way. We began to look at the “services” provided by java classes. We began to look at the “services” provided by java classes. Scanner Scanner System.out System.out Random Random Math Math

Passing 5 to the displayValue Method 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

variable = new ObjectName() Scanner (System.in) keyboard = constructor instantiation new

And of course we had a PA to go along with functions we had a PA to go along with functions Hangman.java Hangman.java

and we learned lots of new terms formal parameterargument visibility modifyer static qualified name return statement return type

On to the last of our “procedural” structures But of course not least…bring on the loops. But of course not least…bring on the loops. infinite loop loop control variable off by one error 4 pre post for do/while while

We saw Stars! * *** ***** ******* ********* ******* ***** *** * ********** ******** ******* ****** ***** **** *** ** * ** *** **** ***** ****** ******* ******** ********* **********

And yet another PA

Objects class – blueprint class – blueprint object – specific house object – specific house

and more terms members members attribute attribute method method visibility modifiers again visibility modifiers again this this static static instantiation constructor overloading mutator accessor immutable mutable

We learned to hand trace methods and objects Back to containers on a desk. Back to containers on a desk. Each container holds its current value. Each container holds its current value. We must change the value as it changes during program execution We must change the value as it changes during program execution Each container must be identified with its scope. Each container must be identified with its scope. And about scope…. And about scope….

block scope inside {} inside {} local - inside method { } local - inside method { } global – inside class { } global – inside class { } visibility is controlled by where the declaration is made. visibility is controlled by where the declaration is made. Careful for (….); Careful for (….);

And even further “scope” static – belongs to the class static – belongs to the class non-static – belongs to individual objects of the class non-static – belongs to individual objects of the class static = 1 container named by the class static = 1 container named by the class non-static = 1 container per object non-static = 1 container per object

And what can we see between classes PrivatePublic

And another PA

and finally arrays subscripted variable subscripted variable reference type reference type arr1[3] arr1[3] One name, many items One name, many items Collections Collections loops – for each loop loops – for each loop index index

and the last pa

Think about how far we have come And how much you have learned. And how much you have learned. What was hard is now easy. What was hard is now easy. What is now hard will continue to become easy. What is now hard will continue to become easy.

Next semester in no particular order Objects, more and more Objects, more and more Inheritance Inheritance Input and output Input and output Exceptions Exceptions Enumerated Types Enumerated Types Abstract Classes Abstract Classes Interfaces Interfaces Polymorphism Polymorphism Recursion Recursion and much much more… and much much more…

Tomorrow’s exam You will have a starter file You will have a starter file You will have to fill in method code You will have to fill in method code You MUST read the documentation for each method that you are to code You MUST read the documentation for each method that you are to code Strategies Strategies read through all of the methods in the class…some may already be built that can help you…some you may build could help you with others. read through all of the methods in the class…some may already be built that can help you…some you may build could help you with others. Work through what you are clearest on first. Then go on to the others Work through what you are clearest on first. Then go on to the others Build stubs so that you can compile as you go along. Compiling will help you find silly mistakes Build stubs so that you can compile as you go along. Compiling will help you find silly mistakes Review the labs from Color139 through to the end of the semester. Make sure you understand what each method does and how it is coded. Review the labs from Color139 through to the end of the semester. Make sure you understand what each method does and how it is coded. Pay attention to input parameters and returns. Pay attention to input parameters and returns. You may start 5 minutes before your section begins and stay for 5 minutes after. You may start 5 minutes before your section begins and stay for 5 minutes after.

Now onto the rest of the review