update all
This commit is contained in:
parent
dbb51c5785
commit
b45b37c887
8
src/main/java/de/vimo/BasicElectronicFunction.java
Normal file
8
src/main/java/de/vimo/BasicElectronicFunction.java
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package de.vimo;
|
||||||
|
|
||||||
|
public interface BasicElectronicFunction {
|
||||||
|
|
||||||
|
void turnOn();
|
||||||
|
|
||||||
|
void turnOff();
|
||||||
|
}
|
||||||
@ -1,14 +0,0 @@
|
|||||||
package de.vimo;
|
|
||||||
|
|
||||||
public class FieldOven {
|
|
||||||
private SizeOfField sizeOfField;
|
|
||||||
private int position;
|
|
||||||
|
|
||||||
public FieldOven() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public SizeOfField getSizeOfField() {
|
|
||||||
return sizeOfField;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
18
src/main/java/de/vimo/HeatTypes.java
Normal file
18
src/main/java/de/vimo/HeatTypes.java
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package de.vimo;
|
||||||
|
|
||||||
|
public class HeatTypes {
|
||||||
|
|
||||||
|
private String heatTypeName;
|
||||||
|
|
||||||
|
public HeatTypes(String heatTypeName) {
|
||||||
|
this.heatTypeName = heatTypeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHeatTypeName(String heatTypeUser) {
|
||||||
|
heatTypeName = heatTypeUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHeatTypeName() {
|
||||||
|
return heatTypeName;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,18 +1,53 @@
|
|||||||
package de.vimo;
|
package de.vimo;
|
||||||
|
|
||||||
public class Oven {
|
public class Oven implements BasicElectronicFunction {
|
||||||
private FieldOven[] fieldOvens;
|
|
||||||
|
private HeatTypes[] heatTypes;
|
||||||
|
private TemperatureLevels[] temperatureLevels;
|
||||||
|
private boolean isHeatTypeButtonPressed;
|
||||||
|
private String currentHeatType;
|
||||||
|
private int currentHeatLevel;
|
||||||
|
|
||||||
public Oven() {
|
public Oven() {
|
||||||
fieldOvens = new FieldOven[4];
|
heatTypes = new HeatTypes[2];
|
||||||
|
temperatureLevels = new TemperatureLevels[4];
|
||||||
|
isHeatTypeButtonPressed = false;
|
||||||
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initializeOven() {
|
public void initialize() {
|
||||||
fieldOvens[0]
|
heatTypes[0] = new HeatTypes("two-sided heat");
|
||||||
|
heatTypes[1] = new HeatTypes("circulating heat");
|
||||||
|
|
||||||
|
temperatureLevels[0] = new TemperatureLevels(100);
|
||||||
|
temperatureLevels[1] = new TemperatureLevels(150);
|
||||||
|
temperatureLevels[2] = new TemperatureLevels(200);
|
||||||
|
temperatureLevels[3] = new TemperatureLevels(250);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void turnOn(FieldOven fieldOven) {
|
public void turnOn() {
|
||||||
|
isHeatTypeButtonPressed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void turnOff() {
|
||||||
|
isHeatTypeButtonPressed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHeatType(String heatType) {
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
if (heatTypes[i].getHeatTypeName().equals(heatType)) {
|
||||||
|
currentHeatType = heatType;
|
||||||
|
System.out.println(heatType + " is set on Position " + i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTemperaturLevel(int level) {
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
if (temperatureLevels[i].getTemperatureLevel() == level) {
|
||||||
|
currentHeatLevel = level;
|
||||||
|
System.out.println(level + " is set on Position " + i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,10 @@ package de.vimo;
|
|||||||
public class OvenApp {
|
public class OvenApp {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Oven siemensOven = new Oven();
|
Oven siemensOven = new Oven();
|
||||||
siemensOven.turnOn(fieldDownLeft);
|
siemensOven.turnOn();
|
||||||
siemensOven.setField(fieldDownLeft, 3);
|
siemensOven.setHeatType("circulating heat");
|
||||||
|
siemensOven.setTemperaturLevel(200);
|
||||||
|
siemensOven.turnOff();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
package de.vimo;
|
package de.vimo;
|
||||||
|
|
||||||
public class Speaker {
|
public class Speaker implements BasicElectronicFunction {
|
||||||
|
|
||||||
private boolean isPowerButtonOn;
|
private boolean isPowerButtonOn;
|
||||||
private boolean isBluetoothButtonOn;
|
private boolean isBluetoothButtonOn;
|
||||||
@ -12,10 +12,14 @@ public class Speaker {
|
|||||||
soundLevel = 0;
|
soundLevel = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void turnOnSpeaker() {
|
public void turnOn() {
|
||||||
isPowerButtonOn = true;
|
isPowerButtonOn = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void turnOff() {
|
||||||
|
isPowerButtonOn = false;
|
||||||
|
}
|
||||||
|
|
||||||
public void connectBluetooth() {
|
public void connectBluetooth() {
|
||||||
isBluetoothButtonOn = true;
|
isBluetoothButtonOn = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ public class SpeakerApp
|
|||||||
public static void main( String[] args )
|
public static void main( String[] args )
|
||||||
{
|
{
|
||||||
Speaker speakerSony = new Speaker();
|
Speaker speakerSony = new Speaker();
|
||||||
speakerSony.turnOnSpeaker();
|
speakerSony.turnOn();
|
||||||
speakerSony.connectBluetooth();
|
speakerSony.connectBluetooth();
|
||||||
speakerSony.increaseSoundVolume(4);
|
speakerSony.increaseSoundVolume(4);
|
||||||
speakerSony.decreaseSoundVolume(3);
|
speakerSony.decreaseSoundVolume(3);
|
||||||
|
|||||||
@ -1,4 +1,66 @@
|
|||||||
package de.vimo;
|
package de.vimo;
|
||||||
|
|
||||||
public class Stove {
|
public class Stove implements BasicElectronicFunction {
|
||||||
|
private final StoveField[][] stoveFields;
|
||||||
|
private String positionName;
|
||||||
|
private boolean isPowerOn;
|
||||||
|
|
||||||
|
public Stove() {
|
||||||
|
stoveFields = new StoveField[2][2];
|
||||||
|
initializeStove();
|
||||||
|
isPowerOn = false;
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initializeStove() {
|
||||||
|
stoveFields[0][0] = new StoveField(SizeOfField.STANDARD_EXTENSION_CIRCLE);
|
||||||
|
stoveFields[1][0] = new StoveField(SizeOfField.SMALL_CIRCLE);
|
||||||
|
stoveFields[0][1] = new StoveField(SizeOfField.STANDARD_CIRCLE);
|
||||||
|
stoveFields[1][1] = new StoveField(SizeOfField.BIG_CIRCLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void turnOn(String stoveFieldName) {
|
||||||
|
switch(stoveFieldName) {
|
||||||
|
case "fieldDownLeft":
|
||||||
|
positionName = "fieldDownLeft";
|
||||||
|
stoveFields[0][1].turnOnField();
|
||||||
|
break;
|
||||||
|
case "fieldDownRight":
|
||||||
|
positionName = "fieldDownRight";
|
||||||
|
stoveFields[1][1].turnOnField();
|
||||||
|
break;
|
||||||
|
case "fieldUpLeft":
|
||||||
|
positionName = "fieldUpLeft";
|
||||||
|
stoveFields[0][0].turnOnField();
|
||||||
|
break;
|
||||||
|
case "fieldUpRight":
|
||||||
|
positionName = "fieldUpRight";
|
||||||
|
stoveFields[1][0].turnOnField();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void turnOn() {
|
||||||
|
isPowerOn = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void turnOff() {
|
||||||
|
isPowerOn = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder result = new StringBuilder().append("Position ")
|
||||||
|
.append(positionName).append(" has size of field ")
|
||||||
|
.append(stoveFields[0][1].getSizeOfField())
|
||||||
|
.append(" with Power is ")
|
||||||
|
.append(stoveFields[0][1].isPowerOn());
|
||||||
|
// for (int i = 0; i < 2; i++) {
|
||||||
|
// for (int j = 0; j < 2; j++) {
|
||||||
|
// result = "Position " + positionName + " has size of field " + stoveFields[i][j].getSizeOfField();
|
||||||
|
// } // ich habe versucht alle Felder und deren Power zustand wieder zugeben, ähnlich wie Chess Board. aber es hat nicht geklappt
|
||||||
|
// }
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package de.vimo;
|
|||||||
public class StoveApp {
|
public class StoveApp {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Stove siemensStove = new Stove();
|
Stove siemensStove = new Stove();
|
||||||
|
siemensStove.turnOn("fieldDownLeft");
|
||||||
|
System.out.println(siemensStove);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
29
src/main/java/de/vimo/StoveField.java
Normal file
29
src/main/java/de/vimo/StoveField.java
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package de.vimo;
|
||||||
|
|
||||||
|
public class StoveField {
|
||||||
|
private SizeOfField sizeOfField;
|
||||||
|
private boolean isPowerOn;
|
||||||
|
|
||||||
|
public StoveField(SizeOfField sizeOfField) {
|
||||||
|
this.sizeOfField = sizeOfField;
|
||||||
|
isPowerOn = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean turnOnField() {
|
||||||
|
isPowerOn = true;
|
||||||
|
return isPowerOn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SizeOfField getSizeOfField() {
|
||||||
|
return sizeOfField;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean turnOffField() {
|
||||||
|
isPowerOn = false;
|
||||||
|
return isPowerOn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPowerOn() {
|
||||||
|
return isPowerOn;
|
||||||
|
}
|
||||||
|
}
|
||||||
18
src/main/java/de/vimo/TemperatureLevels.java
Normal file
18
src/main/java/de/vimo/TemperatureLevels.java
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package de.vimo;
|
||||||
|
|
||||||
|
public class TemperatureLevels {
|
||||||
|
|
||||||
|
private int temperatureLevel;
|
||||||
|
|
||||||
|
public TemperatureLevels(int temperatureLevel) {
|
||||||
|
this.temperatureLevel = temperatureLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTemperatureLevel(int temperatureLevelUser) {
|
||||||
|
temperatureLevel = temperatureLevelUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTemperatureLevel() {
|
||||||
|
return temperatureLevel;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user