From b2b4e340375e92d729dfe466efd616b9bb075311 Mon Sep 17 00:00:00 2001 From: JPANZO Date: Mon, 7 Feb 2022 17:00:23 +0100 Subject: [PATCH] ProjectStructure changed, CD and ExceptionClasses added. --- Geraete.config | 7 +- src/main/java/device/CDPlayer.java | 50 ------------ src/main/java/device/cdPlayer/CD.java | 33 ++++++++ src/main/java/device/cdPlayer/CDPlayer.java | 79 +++++++++++++++++++ .../exceptions/CdFlapIsOpenException.java | 8 ++ .../FormatNotSupportedException.java | 8 ++ .../cdPlayer/exceptions/NoCDException.java | 8 ++ .../device/{ => radioPlayer}/RadioPlayer.java | 4 +- .../device/{ => usbPlayer}/UsbPlayer.java | 4 +- .../device/{ => cdPlayer}/CDPlayerTest.java | 3 +- .../{ => radioPlayer}/RadioPlayerTest.java | 4 +- .../device/{ => usbPlayer}/UsbPlayerTest.java | 2 +- 12 files changed, 152 insertions(+), 58 deletions(-) delete mode 100644 src/main/java/device/CDPlayer.java create mode 100644 src/main/java/device/cdPlayer/CD.java create mode 100644 src/main/java/device/cdPlayer/CDPlayer.java create mode 100644 src/main/java/device/cdPlayer/exceptions/CdFlapIsOpenException.java create mode 100644 src/main/java/device/cdPlayer/exceptions/FormatNotSupportedException.java create mode 100644 src/main/java/device/cdPlayer/exceptions/NoCDException.java rename src/main/java/device/{ => radioPlayer}/RadioPlayer.java (97%) rename src/main/java/device/{ => usbPlayer}/UsbPlayer.java (95%) rename src/test/java/device/{ => cdPlayer}/CDPlayerTest.java (94%) rename src/test/java/device/{ => radioPlayer}/RadioPlayerTest.java (95%) rename src/test/java/device/{ => usbPlayer}/UsbPlayerTest.java (96%) diff --git a/Geraete.config b/Geraete.config index cb2ada9..a98abfd 100644 --- a/Geraete.config +++ b/Geraete.config @@ -1,3 +1,4 @@ -CD=device.CdPlayer -Radio=device.RadioPlayer -USB=device.UsbPlayer \ No newline at end of file +CD=device.cdPlayer.CdPlayer +Radio=device.radioPlayer.RadioPlayer +USB=device.usbPlayer.UsbPlayer + diff --git a/src/main/java/device/CDPlayer.java b/src/main/java/device/CDPlayer.java deleted file mode 100644 index 366ac5f..0000000 --- a/src/main/java/device/CDPlayer.java +++ /dev/null @@ -1,50 +0,0 @@ -package device; - -public class CDPlayer implements Device { - @Override - public void louder() { - - } - - @Override - public void quieter() { - - } - - @Override - public int getVolume() { - return 0; - } - - @Override - public void next() { - - } - - @Override - public void prev() { - - } - - @Override - public String getInfoText() { - return null; - } - - @Override - public String[] getOptions() { - return new String[0]; - } - - @Override - public String[] getItemList() { - return new String[0]; - } - - - @Override - public String play() { - return null; - } - -} diff --git a/src/main/java/device/cdPlayer/CD.java b/src/main/java/device/cdPlayer/CD.java new file mode 100644 index 0000000..e1f61b3 --- /dev/null +++ b/src/main/java/device/cdPlayer/CD.java @@ -0,0 +1,33 @@ +package device.cdPlayer; + +public class CD { + private String format; + private String[] playList; + + public CD() {} + + public CD(String format) { + this.format = format; + } + + public CD(String format, String[] playList) { + this.format = format; + this.playList = playList; + } + + public String getFormat() { + return format; + } + + public void setFormat(String format) { + this.format = format; + } + + public String[] getPlayList() { + return playList; + } + + public void setPlayList(String[] playList) { + this.playList = playList; + } +} diff --git a/src/main/java/device/cdPlayer/CDPlayer.java b/src/main/java/device/cdPlayer/CDPlayer.java new file mode 100644 index 0000000..6cc7b77 --- /dev/null +++ b/src/main/java/device/cdPlayer/CDPlayer.java @@ -0,0 +1,79 @@ +package device.cdPlayer; + +import device.Device; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class CDPlayer implements Device { + + // 0-Leer; true-1 + private int CdDriveContent=0; + private int CdFlap=0; + private int volume = 0; + private List supportedFormats = new ArrayList(Arrays.asList(new String[] {"Audio","MP3","WMA","AAC"})); + + private String actualPlayTrack=""; + private CD loadedCD; + private String[] cdAlbum=new String[]{}; + + + @Override + public void louder() { + + } + + @Override + public void quieter() { + + } + + @Override + public int getVolume() { + return 0; + } + + @Override + public void next() { + + } + + @Override + public void prev() { + + } + + @Override + public String getInfoText() { + return null; + } + + @Override + public String[] getOptions() { + return new String[0]; + } + + @Override + public String[] getItemList() { + return new String[0]; + } + + + @Override + public String play() { + return null; + } + + //Getters und Setters + public void setCD(CD _loadedCD) { + loadedCD=_loadedCD; + this.setCdDriveContent(); + this.actualPlayTrack=loadedCD.getPlayList()[0]; + } + + private void setCdDriveContent() { + CdDriveContent = 1; + } + +} diff --git a/src/main/java/device/cdPlayer/exceptions/CdFlapIsOpenException.java b/src/main/java/device/cdPlayer/exceptions/CdFlapIsOpenException.java new file mode 100644 index 0000000..079e03d --- /dev/null +++ b/src/main/java/device/cdPlayer/exceptions/CdFlapIsOpenException.java @@ -0,0 +1,8 @@ +package device.cdPlayer.exceptions; + +public class CdFlapIsOpenException extends RuntimeException{ + //String message="Cd Flap must be closed."; + public CdFlapIsOpenException() { + super("Cd Flap must be closed."); + } +} diff --git a/src/main/java/device/cdPlayer/exceptions/FormatNotSupportedException.java b/src/main/java/device/cdPlayer/exceptions/FormatNotSupportedException.java new file mode 100644 index 0000000..2b398d2 --- /dev/null +++ b/src/main/java/device/cdPlayer/exceptions/FormatNotSupportedException.java @@ -0,0 +1,8 @@ +package device.cdPlayer.exceptions; + +public class FormatNotSupportedException extends RuntimeException{ + //String message="Cd-Format not supported."; + public FormatNotSupportedException() { + super("Cd-Format not supported."); + } +} diff --git a/src/main/java/device/cdPlayer/exceptions/NoCDException.java b/src/main/java/device/cdPlayer/exceptions/NoCDException.java new file mode 100644 index 0000000..be85d53 --- /dev/null +++ b/src/main/java/device/cdPlayer/exceptions/NoCDException.java @@ -0,0 +1,8 @@ +package device.cdPlayer.exceptions; + +public class NoCDException extends RuntimeException { + //String message="CD must be set."; + public NoCDException() { + super("CD must be set."); + } +} diff --git a/src/main/java/device/RadioPlayer.java b/src/main/java/device/radioPlayer/RadioPlayer.java similarity index 97% rename from src/main/java/device/RadioPlayer.java rename to src/main/java/device/radioPlayer/RadioPlayer.java index ac4fd34..e2cc7d1 100644 --- a/src/main/java/device/RadioPlayer.java +++ b/src/main/java/device/radioPlayer/RadioPlayer.java @@ -1,4 +1,6 @@ -package device; +package device.radioPlayer; + +import device.Device; import java.util.ArrayList; diff --git a/src/main/java/device/UsbPlayer.java b/src/main/java/device/usbPlayer/UsbPlayer.java similarity index 95% rename from src/main/java/device/UsbPlayer.java rename to src/main/java/device/usbPlayer/UsbPlayer.java index a9a6509..87b63ab 100644 --- a/src/main/java/device/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -1,4 +1,6 @@ -package device; +package device.usbPlayer; + +import device.Device; public class UsbPlayer implements Device { diff --git a/src/test/java/device/CDPlayerTest.java b/src/test/java/device/cdPlayer/CDPlayerTest.java similarity index 94% rename from src/test/java/device/CDPlayerTest.java rename to src/test/java/device/cdPlayer/CDPlayerTest.java index 7658a13..eb63e35 100644 --- a/src/test/java/device/CDPlayerTest.java +++ b/src/test/java/device/cdPlayer/CDPlayerTest.java @@ -1,4 +1,4 @@ -package device; +package device.cdPlayer; import org.junit.jupiter.api.Test; @@ -43,4 +43,5 @@ class CDPlayerTest { } */ + } \ No newline at end of file diff --git a/src/test/java/device/RadioPlayerTest.java b/src/test/java/device/radioPlayer/RadioPlayerTest.java similarity index 95% rename from src/test/java/device/RadioPlayerTest.java rename to src/test/java/device/radioPlayer/RadioPlayerTest.java index edb8bd3..1d0549f 100644 --- a/src/test/java/device/RadioPlayerTest.java +++ b/src/test/java/device/radioPlayer/RadioPlayerTest.java @@ -1,5 +1,7 @@ -package device; +package device.radioPlayer; + +import device.radioPlayer.RadioPlayer; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/device/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java similarity index 96% rename from src/test/java/device/UsbPlayerTest.java rename to src/test/java/device/usbPlayer/UsbPlayerTest.java index c9901a1..bf170fe 100644 --- a/src/test/java/device/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -1,4 +1,4 @@ -package device; +package device.usbPlayer; import org.junit.jupiter.api.Test;