Reviewing for Exam Lecture 1?.

Slides:



Advertisements
Similar presentations
Based on Java Software Development, 5th Ed. By Lewis &Loftus
Advertisements

Programmer-defined classes Part 2. Topics Returning objects from methods The this keyword Overloading methods Class methods Packaging classes Javadoc.
Lecture 23 Input and output with files –(Sections 2.13, 8.7, 8.8) Exceptions and exception handling –(Chapter 17)
CS102--Object Oriented Programming
Exceptions Don’t Frustrate Your User – Handle Errors KR – CS 1401 Spring 2005 Picture – sysprog.net.
Java I/O Java I/O is based on input streams and output streams. All input and output are defined in the Java IO package. 1.
CS 116 OBJECT ORIENTED PROGRAMMING II LECTURE 10 GEORGE KOUTSOGIANNAKIS Copyright: 2014 Illinois Institute of Technology/ George Koutsogiannakis 1.
EXCEPTIONS. What’s an exception?? Change the flow of control when something important happens ideally - we catch errors at compile time doesn’t happen.
Slides prepared by Rose Williams, Binghamton University ICS201 Exception Handling University of Hail College of Computer Science and Engineering Department.
1 Chapter 4 Language Fundamentals. 2 Identifiers Program parts such as packages, classes, and class members have names, which are formally known as identifiers.
交通大學資訊工程學系 Programming in Java Exception Handling 蔡文能 交通大學資訊工程學系
Java Exception Handling ● Exception = an event that occurs during the execution of a program that disrupts the normal flow of instructions: – Examples:
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Example 1 :- Handling integer values public class Program1 { public static void main(String [] args) { int value1, value2, sum; value1 = Integer.parseInt(args[0]);
CSC172 Intro Pepper. Goals Reminder of what a class is How to create and use classes How to design classes How to think in terms of objects How to comment.
CS 2511 Fall  Exception = an event that occurs during the execution of a program that disrupts the normal flow of instructions:  Examples: Out.
Java I/O Java I/O is based on input streams and output streams. All input and output are defined in the Java IO package. 1.
Object Based Programming Chapter 8. 2 In This Chapter We will learn about classes Garbage Collection Data Abstraction and encapsulation.
Exceptions By the end of this lecture you should be able to: explain the term exception; distinguish between checked and unchecked exception classes in.
Reviewing for Exam Lecture 12. Lab 1 Postfix.java –Hexadecimal Converting ‘a’ to number Converting ‘1’ to number –System.exit(3); Questions?
CPRG 215 Introduction to Object-Oriented Programming with Java Module 4- Exception and Error Handling Topic 4.1 Errors and Exceptions Produced by Harvey.
CSE 143 Lecture 4 More ArrayIntList : Pre/postconditions; exceptions; testing reading: slides created by Marty Stepp and Hélène Martin
Building Java Programs Chapter 15 Lecture 15-2: testing ArrayIntList; pre/post conditions and exceptions reading:
Python – May 16 Recap lab Simple string tokenizing Random numbers Tomorrow: –multidimensional array (list of list) –Exceptions.
CSC Java Programming, Fall, 2008 Week 3: Objects, Classes, Strings, Text I/O, September 11.
Java Programming: Exceptions1 Exceptions Reference: java.sun.com/docs/books/tutorial/essential/exceptions/
Lecture10 Exception Handling Jaeki Song. Introduction Categories of errors –Compilation error The rules of language have not been followed –Runtime error.
Exceptions and Error Handling. Exceptions Errors that occur during program execution We should try to ‘gracefully’ deal with the error Not like this.
Garbage Collection It Is A Way To Destroy The Unused Objects. To do so, we were using free() function in C language and delete() in C++. But, in java it.
A High Flying Overview CS139 – Fall 2010 How far we have come.
CS 116 Object Oriented Programming II Lecture 10 Acknowledgement: Contains materials provided by George Koutsogiannakis and Matt Bauer.
Lecture 7 D&D Chapter 7 & 8 Composite Classes and enums Date.
Exceptions In this lecture:
Chapter 10 – Exception Handling
OBJECT ORIENTED PROGRAMMING II LECTURE 10 GEORGE KOUTSOGIANNAKIS
INTERACTIVE OUTER SPACE GAME
OBJECT ORIENTED PROGRAMMING II LECTURE 2 GEORGE KOUTSOGIANNAKIS
Testing and Debugging.
Introduction to OO Program Design
CS102 – Exceptions David Davenport Latest: May 2015
Chapter 12 Exception Handling and Text IO
Testing and Exceptions
CS Week 10 Jim Williams, PhD.
CS Week 14 Jim Williams, PhD.
CSS161: Fundamentals of Computing
CS 302 Week 10 Jim Williams.
Session 5: Array, Generic, Exception Handling.
Handling Exceptions.
Object Based Programming
E x c e p t i o n s Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. — Martin Golding.
File I/O ICS 111: Introduction to Computer Science I
Implementing Non-Static Features
TRY CATCH BLOCK By Kosala Rajapaksha.
Exception Handling.
More On Enumeration Types
Web Design & Development Lecture 7
Algorithm Correctness
More About Objects and Methods
Managing Errors and Exceptions
Basics of OOP A class is the blueprint of an object.
Additional information re files
Outline Anatomy of a Class Encapsulation Anatomy of a Method
Java Programming Exceptions CSC 444 By Ralph B. Bisland, Jr.
Tutorial Exceptions Handling.
Chapter 12 Exception Handling and Text IO Part 1
Exception Handling Contents
E x c e p t i o n s Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. — Martin Golding.
Tutorial MutliThreading.
The Planets of our Solar System The Terrestrial Planets
Exception Objects An exception is an abnormal condition that arises in a code sequence at rum time. Exception is a way of signaling serious problem.
Presentation transcript:

Reviewing for Exam Lecture 1?

Lab 1 Postfix.java Questions? Hexadecimal System.exit(3); Converting ‘a’ to number Converting ‘1’ to number System.exit(3); Questions?

Lecture 1 Test cases for programs Documentation Echo of input Inline comments Ending message Javadocs

Lab 2 PseudoWar game Required Test cases Stubs Program Constructors Specific methods Generation of number in range 1 to 52

Lab 3 Exception Handlers Avoiding Try Catch printStackTrace() getMessage() Multiple handlers Avoiding

Lecture 3 Style guidelines Chapter12 slides

Lab 4 Writing code from scratch Illustrating use of exception handlers Illustrating avoidance of exceptions Java Tutorial Java api

ArithmeticException ArrayIndexOutOfBoundsException FileNotFoundException PatternSyntaxException ClassNotFoundException InputMisMatchException NullPointerException NumberFormatException StringIndexOutOfBoundsException NegativeArraySizeException ArrayStoreException MalformedURLException IOException IllegalArgumentException ClassCastExceptionIllegal FormatConversionException

Lecture 4 Common Exceptions Reading from Files Compile time errors That can be avoided That can not be avoided Reading from Files Compile time errors Runtime errors

Lab 5 File I/O Use of command line arguments Use of re-direct symbols PrintWriter (flush) File java.io package Use of command line arguments Use of re-direct symbols

Lecture 5 Play with text examples Use of StringTokenizer Use of delimiters Use of regular expressions Correct use of Boolean in if and while statements How comments help

Lab 6 Enumerated types Enhanced for loop (i.e. for… each)

Lecture 6 public enum Sessions { SPRING, SUMMER, FALL ; }

public enum Planet { MERCURY (3.303e+23, 2.4397e6), VENUS (4.869e+24, 6.0518e6), EARTH (5.976e+24, 6.37814e6), MARS (6.421e+23, 3.3972e6), JUPITER (1.9e+27, 7.1492e7), SATURN (5.688e+26, 6.0268e7), URANUS (8.686e+25, 2.5559e7), NEPTUNE (1.024e+26, 2.4746e7); … for (Planet p : Planet.values()) System.out.printf ("Your weight on %s is %f%n", p, p.surfaceWeight(mass));

Lab 7 Enumerated types again Order Valid elements Attributes Rank Suit Card Deck (?) Order Valid elements Attributes

Example for-each for (Rank r : Rank.values()) { System.out.println r.getBridgePoints() + " " + r.getAbbreviation() ); } // end for

Lecture 7 Chapter 9 – Chapter_9_Part1.ppt slides ClearJunk.java

Lab 8 Classes toString methods equals methods static fields when needed how used static fields

Lecture 8 A few things Chapter 9 – rest of slides

Lab 9 UML diagram Die objects getFaceValue setFaceValue toString Roll Math.random vs Random

Lecture 9 Talk about constructors belongs to class do not have a visibility modifier same name as class may have no parameters (no-arg constructor) may have one or more parameters (explicit value constructor) class may have no explicit constructor class may have more than one constructor doesn't return values

Lab 10 Code re-use Array of objects Explicit value constructors No-arg constructors Reading carefully

Lecture 10 Professor Harris lecture – see blackboard

Lab 11 Designing classes DISCUSSION Getters and setters are, in general, public methods. Since Fraction is immutable, shouldn’t have them. Fraction is 4/20 not .20 Numerator and denominator are ints

Lecture 11 Somewhat of a repetition of lecture 10

Lab 12 Inheritance Employee SalariedWorker HourlyWorker

Lecture 12

Lab 13 Specialization and Inheritance DISCUSSION Needed to look at javadocs Can’t compare one ampm to another using == because they are Strings – need .equals An AlarmClock is-a Clock (a Clock is NOT an AlarmClock).