Das Programm kompiliert zwar, gibt aber nichts aus. Ich weiß leider nicht, was ich machen soll.
Java:
public class Buch {
private String titel;
private double preis;
private long barcode;
private int seiten;
private String autor;
private int auflage;
private String beschreibung;
public String getTitel(){
return titel;
}
public double getPreis() {
return preis;
}
public long getBarcode() {
return barcode;
}
public int getSeiten() {
return seiten;
}
public String getAutor() {
return autor;
}
public int getAuflage() {
return auflage;
}
public void setTitel (String titel){
this.titel = titel;
}
public void setPreis (double preis){
this.preis = preis;
}
public void setBarcode (long barcode){
this.barcode = barcode;
}
public void setSeiten (int seiten){
this.seiten = seiten;
}
public void setAutor (String autor){
this.autor = autor;
}
public void setAuflage (int auflage){
this.auflage = auflage;
}
public String getBeschreibung(){
return "Buch" + titel + "von" + autor + "," + auflage + "Auflage" + seiten + "Seiten";
}
public void setBeschreibung (String beschreibung) {
this.beschreibung = beschreibung;
}
public Buch (String titel, double preis, long barcode, int seiten, String autor, int auflage) {
this.titel = titel;
this.preis = preis;
this.barcode = barcode;
this.seiten = seiten;
this.autor = autor;
this.auflage = auflage;
}
}
Code:
public class WebshopTest {
public static void main (String[] args) {
Buch b1 = new Buch ("UML 2.0", 9.8, 97857657657L, 139, "Dan Pilone", 2);
System.out.println(b1.getBeschreibung());
System.out.println("Preis: " + b1.getPreis() + " Euro");
System.out.println("Barcode: " + b1.getBarcode());
}
}