Hallo
Ich bräuchte Hilfe bei folgender Aufgabe.
1) Stimmt das so mit der abstrakten Klasse und den Unterklassen?
2) Versuche mich grade an dem printInformations . Wie werden denn die Werte hinter dem new Object übergeben? Bzw. wie schreibe ich diese Methode?
Hauptprogramm
Abstrakte Oberklasse
Unterklasse
Unterklasse
Unterklasse
Danke schonmal
Ich bräuchte Hilfe bei folgender Aufgabe.
1) Stimmt das so mit der abstrakten Klasse und den Unterklassen?
2) Versuche mich grade an dem printInformations . Wie werden denn die Werte hinter dem new Object übergeben? Bzw. wie schreibe ich diese Methode?
Hauptprogramm
Java:
public class Main {
public static void main(String[] args) {
// Has to be a syntax error:
// CommunicationDevice c = new CommunicationDevice("c");
CommunicationDevice compA = new Computer("Comp A", "0.0.0.1");
CommunicationDevice compB = new Computer("Comp B", "0.0.0.2");
CommunicationDevice phoneA = new SmartPhone("SmartPhone A");
CommunicationDevice phoneB = new SmartPhone("SmartPhone B");
CommunicationDevice faxA = new Fax("Fax A", "1234");
CommunicationDevice faxB = new Fax("Fax B", "5678");
// compA.addContact(phoneA);
// compA.addContact(faxA);
Out.println("//generated by printInformations()-calls:");
compA.printInformations();
compB.printInformations();
phoneA.printInformations();
phoneB.printInformations();
faxA.printInformations();
faxB.printInformations();
/* Out.println();
Out.println("//generated by compA.receiveMessage(compB):");
compA.receiveMessage(compB);
Out.println();
Out.println("//generated by compB.sendMessage(compA):");
compB.sendMessage(compA);
Out.println("//generated by phoneB.sendMessage(faxB):");
phoneB.sendMessage(faxB);
Out.println("//generated by phoneB.sendMessage(compB):");
phoneB.sendMessage(compB);
Out.println("//generated by faxB.sendMessage(compB):");
faxB.sendMessage(compB);
Out.println("//generated by compA.broadcast():");
compA.broadcast();
*/
}
}
Java:
abstract class CommunicationDevice {
//void addContact();
// void printInformations();
// void receivedMessage();
//void sendMessage();
//void broadcast();
}
Unterklasse
Java:
public class Computer {
private String Name;
private int IP;
//void addContact();
// void printInformations();
//void receivedMessage();
//void sendMessage();
//void broadcast();
}
Unterklasse
Java:
public class Smartphone {
private String Name;
//void addContact();
// void printInformations();
// void receivedMessage();
// void sendMessage();
// void broadcast();
}
Unterklasse
Java:
public class Fax {
private String Name;
private int FaxNumber;
// void addContact();
// void printInformations();
// void receivedMessage();
// void sendMessage();
//void broadcast();
}
Danke schonmal