Add interfaces and abstract

This commit is contained in:
acp059
2020-04-29 13:38:30 +02:00
parent ec35c97a6f
commit c0c7a256ba
2 changed files with 74 additions and 0 deletions

View File

@ -5,3 +5,30 @@ url: https://git.haw-hamburg.de/pm1-tutorium/slides
header: Programmieren 1 **Tutorium**
footer: Henri Burau und Eva Meinen
-->
# Interfaces
Schnittstelle
nur Methodendeklaration (öffentliche Methoden)
```java
interface Shape {
double getArea();
String toString();
}
```
---
Erbende Klassen implementieren ein Interface (auch mehr als eines möglich)
```java
class Circle implements Shape {
private double radius;
double getArea(){
return 3.14 * radius * radius;
}
String toString() {
return "Circle";}
}
```