(4 slides per page) - Updated
(4 slides per page) - Updated
(4 slides per page) - Updated
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Overview<br />
Phase 10<br />
Introduction<br />
Notations<br />
Java<br />
Implementation<br />
of modules<br />
Module Tests<br />
Procedure<br />
Example - TLC<br />
Example - SBC<br />
Phase 11<br />
Phase 12<br />
Summary<br />
Overview<br />
Phase 10<br />
Introduction<br />
Notations<br />
Java<br />
Implementation<br />
of modules<br />
Module Tests<br />
Procedure<br />
Example - TLC<br />
Example - SBC<br />
Phase 11<br />
Phase 12<br />
Summary<br />
Interface Classes<br />
A class where all methods are abstract can be declared as<br />
an interface.<br />
A class can implement several interfaces (keyword<br />
implements), but it can only extend one other class.<br />
A class can be accessed using the interface.<br />
An interface class has no constructor.<br />
Solves problem of multiple inheritance.<br />
Exceptions<br />
Methods can throw exceptions<br />
public int div(int n1, int n2) throws Exception {<br />
if (n2==0) throw Exception;<br />
...<br />
}<br />
Exceptions can be handled with try and catch<br />
try {<br />
a = div(b,c);<br />
} catch (Exception e) {<br />
System.out.println(e);<br />
}<br />
Other exceptions are e.g. IOException,<br />
ClassNotFoundException, ArithmeticException,<br />
OutOfMemoryError, Error.<br />
13 / 89<br />
15 / 89<br />
Overview<br />
Phase 10<br />
Introduction<br />
Notations<br />
Java<br />
Implementation<br />
of modules<br />
Module Tests<br />
Procedure<br />
Example - TLC<br />
Example - SBC<br />
Phase 11<br />
Phase 12<br />
Summary<br />
Overview<br />
Phase 10<br />
Introduction<br />
Notations<br />
Java<br />
Implementation<br />
of modules<br />
Module Tests<br />
Procedure<br />
Example - TLC<br />
Example - SBC<br />
Phase 11<br />
Phase 12<br />
Summary<br />
Interface Classes: Example<br />
<br />
animal<br />
abstract makesound()<br />
<br />
dog<br />
cat<br />
makesound() makesound()<br />
Assertions<br />
public interface Animal {<br />
public void makeSound();<br />
}<br />
public class Cat implements Animal {<br />
public Cat(){}<br />
public void makeSound()<br />
{System.out.println("miaow");}<br />
}<br />
public class Dog implements Animal {<br />
public Dog(){}<br />
public void makeSound()<br />
{System.out.println("woof-woof");}<br />
}<br />
public class Main{<br />
public static void main(String[] args) {<br />
Animal a1 = new Dog();<br />
Animal a2 = new Cat();<br />
a1.makeSound(); a2.makeSound();<br />
}<br />
}<br />
14 / 89<br />
Assertions can be used to specify (and check) the<br />
pre-conditions of a method.<br />
Assertions are defined using<br />
assert condition==true: "ErrorString";<br />
Assertions are introduced in Java 1.5, they are only<br />
evaluated using the execution switch “evaluate assertions”:<br />
java -ea<br />
Exceptions thrown by assertions cannot be caught.<br />
16 / 89