Softwaretechnologie I / Übung I
slides.com/phdd/st1e1/live
Wer sind Sie und warum sollte ich zuhören?
Was ist diese Veranstaltung nicht?
Was wird mir geboten?
Was wird von mir erwartet?
Wo finde ich das Material?
class Library {
Book[] myBooks;
int number;
Library() {/*...*/}
void register(Book book) {/*...*/}
}
class Book {
String title;
Book(String title) {/*...*/}
String toString() {/*...*/}
}
0..10 myBooks
0
2
0..10 myBooks
public class Book {
private String title;
public Book(String title) {
this.title = title;
}
public String toString() {
return title;
}
}
public class Library {
private Book[] myBooks;
private int number;
public Library() {
myBooks = new Book[10];
number = 0;
System.out.println("Hello, I am a small library for at most 10 books.");
}
public void register(Book book) {
myBooks[number] = book;
number += 1;
System.out.println("A new book is registered: " + book);
}
}
public class HelloLibrary {
public static void main(String[] args) {
// Objekt für Bibliothek instanziieren
// Bücher instanziieren
// Bücher in Bibliothek registrieren
}
}
$ javac Book.java Library.java HelloLibrary.java
$ java -classpath . HelloLibrary
pehei.de
slides.com/phdd
twitter.com/_phdd