Presentation is loading. Please wait.

Presentation is loading. Please wait.

Reviewing for Exam Lecture 12. Lab 1 Postfix.java –Hexadecimal Converting ‘a’ to number Converting ‘1’ to number –System.exit(3); Questions?

Similar presentations


Presentation on theme: "Reviewing for Exam Lecture 12. Lab 1 Postfix.java –Hexadecimal Converting ‘a’ to number Converting ‘1’ to number –System.exit(3); Questions?"— Presentation transcript:

1 Reviewing for Exam Lecture 12

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

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

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

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

6 Lecture 3 Style guidelines Chapter12 slides

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

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

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

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

11 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

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

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

14 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));

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

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

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

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

19 Lecture 8 A few things Chapter 9 – rest of slides

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

21 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

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

23 Lecture 10 Professor Harris lecture – see blackboard

24 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

25 Lecture 11 Somewhat of a repetition of lecture 10

26 Lab 12 Inheritance –Employee SalariedWorker HourlyWorker

27 Lecture 12 Review

28 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).


Download ppt "Reviewing for Exam Lecture 12. Lab 1 Postfix.java –Hexadecimal Converting ‘a’ to number Converting ‘1’ to number –System.exit(3); Questions?"

Similar presentations


Ads by Google