Commit 86b901dc authored by matthias's avatar matthias
Browse files

added Videothek

parent 5872be02
......@@ -2,7 +2,15 @@ package videothek;
public class CD extends Medium {
private int playTime;
private int amountTracks;
protected int playTimeMin;
protected int amountTracks;
public CD(){
}
public CD(float price){
super(price);
}
}
......@@ -7,7 +7,7 @@ public class HoerspielCD extends CD {
@Override
public void lendMedia() {
super.lendMedia();
public float lendMedia() {
return super.lendMedia() +1.5f;
}
}
......@@ -2,22 +2,22 @@ package videothek;
public class Medium {
private float price;
private boolean isLent;
protected float price;
public boolean isLent;
public Medium() {
}
public Medium(float price) {
this.price = price;
isLent = false;
}
public void lendMedia() {
public float lendMedia() {
isLent = true;
return price;
}
}
......@@ -4,4 +4,19 @@ public class MusikCD extends CD {
public String nameAlbum;
public String artist;
public MusikCD(float price, int playTimeMin) {
super(price);
super.playTimeMin = playTimeMin;
}
@Override
public float lendMedia() {
if (playTimeMin <= 20) {
return super.lendMedia() - 0.5f;
}
return super.lendMedia();
}
}
package videothek;
public class Programm {
public static void main(String[] args){
public static void main(String[] args) {
Videothek videothek = new Videothek();
Medium[] allMedia = new Medium[6];
Medium[] lentMedia = new Medium[6];
Medium media = new Medium(3);
Medium media2 = new Medium(3);
VHS vhs = new VHS();
VHS video = new VHS(3, true);
VHS video1 = new VHS(3, false);
vhs.lendMedia();
MusikCD musik = new MusikCD(3, 10);
MusikCD musik1 = new MusikCD(3, 25);
allMedia[0] = media;
allMedia[1] = media2;
allMedia[2] = video;
allMedia[3] = video1;
allMedia[4] = musik;
allMedia[5] = musik1;
//videothek.lendAllMedia(allMedia);
videothek.lendFirstThreeMedia();
//System.out.println(lentMedia[2].price);
}
}
......@@ -5,11 +5,20 @@ public class VHS extends Medium {
boolean isClassic;
public VHS(float price, boolean isClassic){
super(price);
this.isClassic = isClassic;
}
@Override
public void lendMedia() {
super.lendMedia();
System.out.println("VHS");
public float lendMedia() {
if (isClassic) {
return super.lendMedia() + 1;
}
return super.lendMedia();
}
}
package videothek;
import java.lang.reflect.Array;
public class Videothek {
int[] allMedia;
int[] lentMedia;
Medium[] lentMedia;
public float lendAllMedia(Medium... medien) {
float summary = 0;
for (Medium m : medien) {
summary += m.lendMedia();
System.out.println("Der Leihstatus des Mediums ist: " + m.isLent);
}
System.out.println("- -- -- -- -- -- -- -- -- -- -- -- -");
System.out.println("Der Gesamtpreis beträgt: " + summary + " Euro.");
return summary;
}
public float lendFirstThreeMedia(){
float summary = 0;
for (int i = 0; i <=2; i++){
summary += allMedia[i].price;
}
System.out.println("Der Gesamtpreis beträgt: " + summary + " Euro.");
return summary;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment