+Alles zusammen
parent
a5b1784e05
commit
4a49790666
@ -1,19 +1,30 @@
|
||||
package com.company.audioEffekte;
|
||||
|
||||
public class AudioEffectPlayer {
|
||||
private String[] audioEffect;
|
||||
|
||||
public void play(int index){
|
||||
|
||||
private Audioeffekt[] effects = new Audioeffekt[10];
|
||||
private int index = 0;
|
||||
|
||||
public void play(int indexID) {
|
||||
if (indexID < index) {
|
||||
effects[indexID].play();
|
||||
}
|
||||
}
|
||||
public void addEffect(Audioeffekt audioeffekt){
|
||||
|
||||
|
||||
public void addEffect(Audioeffekt effect) {
|
||||
if (index < effects.length) {
|
||||
effects[index] = effect;
|
||||
index++;
|
||||
} else {
|
||||
System.out.println("Alle Plätze belegt");
|
||||
}
|
||||
}
|
||||
public void removeEffect(int index){
|
||||
|
||||
|
||||
public void removeEffect(int stelleRemove) {
|
||||
effects[stelleRemove] = null;
|
||||
for (int j = stelleRemove; stelleRemove < index; stelleRemove++) {
|
||||
effects[j] = effects[j + 1];
|
||||
}
|
||||
index = index - 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
package com.company.audioEffekte;
|
||||
|
||||
abstract class Audioeffekt {
|
||||
public abstract class Audioeffekt {
|
||||
|
||||
protected String dateiname;
|
||||
|
||||
public Audioeffekt(String dateiname){
|
||||
private String dateiname;
|
||||
|
||||
public Audioeffekt(String filename) {
|
||||
this.dateiname = filename;
|
||||
}
|
||||
|
||||
public void playEffect(){
|
||||
|
||||
public void play() {
|
||||
System.out.println("Effect: " + dateiname);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
package com.company.audioEffekte;
|
||||
|
||||
public class MP3Effekt extends Audioeffekt {
|
||||
|
||||
public MP3Effekt(String dateiname){
|
||||
this.dateiname = "MP3Effekt";
|
||||
|
||||
public MP3Effekt(String filename) {
|
||||
super(filename);
|
||||
}
|
||||
}
|
@ -1,9 +1,7 @@
|
||||
package com.company.audioEffekte;
|
||||
|
||||
public class OGGEffekt extends Audioeffekt{
|
||||
|
||||
public OGGEffekt(String dateiname){
|
||||
this.dateiname = "OGGEffect";
|
||||
|
||||
public class OGGEffekt extends Audioeffekt {
|
||||
public OGGEffekt(String filename) {
|
||||
super(filename);
|
||||
}
|
||||
}
|
@ -1,9 +1,7 @@
|
||||
package com.company.audioEffekte;
|
||||
|
||||
public class WAVEffect extends Audioeffekt{
|
||||
|
||||
public WAVEffect(String dateiname){
|
||||
this.dateiname = "WAVEffect";
|
||||
|
||||
public class WAVEffect extends Audioeffekt {
|
||||
public WAVEffect(String filename) {
|
||||
super(filename);
|
||||
}
|
||||
}
|
@ -1,5 +1,68 @@
|
||||
package com.company.audioEffekte;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
public class main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
AudioEffectPlayer player = new AudioEffectPlayer();
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
|
||||
MP3Effekt mp3 = new MP3Effekt("MP3 File");
|
||||
WAVEffect WAV = new WAVEffect("WAV File");
|
||||
OGGEffekt OGG = new OGGEffekt("OGG File");
|
||||
|
||||
int bisStop = 0;
|
||||
String programmAuswahl = "";
|
||||
|
||||
|
||||
System.out.println("Wählen sie bitte eine der folgende Aktionen aus: ");
|
||||
System.out.println("add = Fügt ein Effekt hinzu (mp3; OGG; WAV) ");
|
||||
System.out.println("rem = Löscht ein Effect im ausgewählten Platz ");
|
||||
System.out.println("show = Zeigt den Effect auf dem jeweiligen Platz an ");
|
||||
System.out.println("showall = Zeigt alle Effecte an ");
|
||||
System.out.println("x = Programm beenden");
|
||||
|
||||
while (bisStop != 1) {
|
||||
|
||||
programmAuswahl = scanner.nextLine().replace("-", "");
|
||||
|
||||
if (programmAuswahl.equals("add")) {
|
||||
System.out.println("Welcher Effect soll hinzugefügt werden? ");
|
||||
String neuerADD = scanner.nextLine().replace("-", "");
|
||||
if (neuerADD.equals("mp3")) {
|
||||
player.addEffect(mp3);
|
||||
System.out.println("mp3 hinzugefügt");
|
||||
} else if (neuerADD.equals("OGG")) {
|
||||
player.addEffect(OGG);
|
||||
System.out.println("OGG hinzugefügt");
|
||||
} else if (neuerADD.equals("WAV")) {
|
||||
player.addEffect(WAV);
|
||||
System.out.println("WAV hinzugefügt");
|
||||
} else {
|
||||
System.out.println("Effekt nicht verfügbar");
|
||||
}
|
||||
|
||||
}else if (programmAuswahl.equals("rem")) {
|
||||
System.out.println("Welcher Platz soll gelöscht werden? ");
|
||||
int NeuerREM = Integer.parseInt(scanner.nextLine().replace("-", ""));
|
||||
player.removeEffect(NeuerREM);
|
||||
|
||||
}else if (programmAuswahl.equals("show")) {
|
||||
|
||||
System.out.println("Welcher Platz soll ausgelesen werden? ");
|
||||
int neuerSHOW = Integer.parseInt(scanner.nextLine().replace("-", ""));
|
||||
player.play(neuerSHOW);
|
||||
}else if (programmAuswahl.equals("showall")) {
|
||||
for(int q = 0; 20 > q; q++){
|
||||
player.play(q);
|
||||
}
|
||||
}else if (programmAuswahl.equals("x")) {
|
||||
bisStop = 1;
|
||||
}else{
|
||||
System.out.println("Programm existiert nicht");
|
||||
}
|
||||
}
|
||||
System.out.println("!!!!! Programm wurde beendet oder ist abgestürtzt !!!!!");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue