Reviewing for Exam Lecture 12
Lab 1 Postfix.java –Hexadecimal 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 –Test cases –Stubs –Program Required –Constructors –Specific methods –Generation of number in range 1 to 52
Lab 3 Exception –Handlers 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 –That can be avoided –That can not be avoided Reading from Files Compile time errors Runtime errors
Lab 5 File I/O –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, e6), VENUS (4.869e+24, e6), EARTH (5.976e+24, e6), MARS (6.421e+23, e6), JUPITER (1.9e+27, e7), SATURN (5.688e+26, e7), URANUS (8.686e+25, e7), NEPTUNE (1.024e+26, e7); … for (Planet p : Planet.values()) System.out.printf ("Your weight on %s is %f%n", p, p.surfaceWeight(mass));
Lab 7 Enumerated types again –Rank –Suit –Card –Deck (?) Order Valid elements Attributes
for (Rank r : Rank.values()) { System.out.println ( r + " " + r.getBridgePoints() + " " + r.getAbbreviation() ); } // end for Example for-each
Lecture 7 Chapter 9 – Chapter_9_Part1.ppt slides ClearJunk.java
Lab 8 Classes –toString methods –equals methods 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 Review
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).