update all

This commit is contained in:
happymeal2024 2025-05-20 09:03:21 +02:00
parent dbb51c5785
commit b45b37c887
11 changed files with 192 additions and 28 deletions

View File

@ -0,0 +1,8 @@
package de.vimo;
public interface BasicElectronicFunction {
void turnOn();
void turnOff();
}

View File

@ -1,14 +0,0 @@
package de.vimo;
public class FieldOven {
private SizeOfField sizeOfField;
private int position;
public FieldOven() {
}
public SizeOfField getSizeOfField() {
return sizeOfField;
}
}

View 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;
}
}

View File

@ -1,18 +1,53 @@
package de.vimo;
public class Oven {
private FieldOven[] fieldOvens;
public class Oven implements BasicElectronicFunction {
private HeatTypes[] heatTypes;
private TemperatureLevels[] temperatureLevels;
private boolean isHeatTypeButtonPressed;
private String currentHeatType;
private int currentHeatLevel;
public Oven() {
fieldOvens = new FieldOven[4];
heatTypes = new HeatTypes[2];
temperatureLevels = new TemperatureLevels[4];
isHeatTypeButtonPressed = false;
initialize();
}
public void initializeOven() {
fieldOvens[0]
public void initialize() {
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);
}
}
}
}

View File

@ -3,7 +3,10 @@ package de.vimo;
public class OvenApp {
public static void main(String[] args) {
Oven siemensOven = new Oven();
siemensOven.turnOn(fieldDownLeft);
siemensOven.setField(fieldDownLeft, 3);
siemensOven.turnOn();
siemensOven.setHeatType("circulating heat");
siemensOven.setTemperaturLevel(200);
siemensOven.turnOff();
}
}

View File

@ -1,6 +1,6 @@
package de.vimo;
public class Speaker {
public class Speaker implements BasicElectronicFunction {
private boolean isPowerButtonOn;
private boolean isBluetoothButtonOn;
@ -12,10 +12,14 @@ public class Speaker {
soundLevel = 0;
}
public void turnOnSpeaker() {
public void turnOn() {
isPowerButtonOn = true;
}
public void turnOff() {
isPowerButtonOn = false;
}
public void connectBluetooth() {
isBluetoothButtonOn = true;
}

View File

@ -6,7 +6,7 @@ public class SpeakerApp
public static void main( String[] args )
{
Speaker speakerSony = new Speaker();
speakerSony.turnOnSpeaker();
speakerSony.turnOn();
speakerSony.connectBluetooth();
speakerSony.increaseSoundVolume(4);
speakerSony.decreaseSoundVolume(3);

View File

@ -1,4 +1,66 @@
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();
}
}

View File

@ -3,6 +3,7 @@ package de.vimo;
public class StoveApp {
public static void main(String[] args) {
Stove siemensStove = new Stove();
siemensStove.turnOn("fieldDownLeft");
System.out.println(siemensStove);
}
}

View 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;
}
}

View 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;
}
}