i need this assignment i’m doing a group project (the detail are in the picture)
ID: 3718473 • Letter: I
Question
i need this assignment i’m doing a group project (the detail are in the picture) i got assign to do the classes for the streetlight and temperature. the streetlight class will just need the light color and and intensity of the light with frequency to determine. it will determine when it’s dim and when to turn on and off. also when to turn on when a emergency is near by,. The temperature class determine when to turn on/dim and off depending on the temperature. it should be base on the details in the picture. i have a rough draft of it. just need it to be more detailed plz code is below: //-------------- Streetlight.java-----------public class Streetlight {
private Status status;
public Streetlight() {
}
public Streetlight(Status status) {
this.status = status;
}
public String getStatus() {
return status.name();
}
public void setOff() {
this.status = Status.OFF;
}
public void setOn() {
this.status = Status.ON;
}
public void setFlickerRed() {
this.status = Status.FLICKER_RED;
}
@Override
public String toString() {
return "Streetlight [status=" + status + "]";
}
}
// enum of status of the light,
// since a street light LED can be in only one state at a time
enum Status {
ON, OFF, DIM, FLICKER_RED
}
//---------- Temperature.java -----------------
public class Temperature {
private float value;
private String unit; // degree / Fahrenheit
public Temperature() {
}
public Temperature(float value, String unit) {
this.value = value;
this.unit = unit;
}
@Override
public String toString() {
return "Temperature [value=" + value + ", unit=" + unit + "]";
}
} //-------------- Streetlight.java-----------
public class Streetlight {
private Status status;
public Streetlight() {
}
public Streetlight(Status status) {
this.status = status;
}
public String getStatus() {
return status.name();
}
public void setOff() {
this.status = Status.OFF;
}
public void setOn() {
this.status = Status.ON;
}
public void setFlickerRed() {
this.status = Status.FLICKER_RED;
}
@Override
public String toString() {
return "Streetlight [status=" + status + "]";
}
}
// enum of status of the light,
// since a street light LED can be in only one state at a time
enum Status {
ON, OFF, DIM, FLICKER_RED
}
//---------- Temperature.java -----------------
public class Temperature {
private float value;
private String unit; // degree / Fahrenheit
public Temperature() {
}
public Temperature(float value, String unit) {
this.value = value;
this.unit = unit;
}
@Override
public String toString() {
return "Temperature [value=" + value + ", unit=" + unit + "]";
}
}
Explanation / Answer
Solution:
//-------------- Streetlight.java-----------
public class Streetlight {
private Status status;
public Streetlight() {
}
public Streetlight(Status status) {
this.status = status;
}
public String getStatus() {
return status.name();
}
public void setOff() {
this.status = Status.OFF;
}
public void setOn() {
this.status = Status.ON;
}
public void setFlickerRed() {
this.status = Status.FLICKER_RED;
}
@Override
public String toString() {
return "Streetlight [status=" + status + "]";
}
}
// enum of status of the light,
// since a street light LED can be in only one state at a time
enum Status {
ON, OFF, DIM, FLICKER_RED
}
//---------- Temperature.java -----------------
public class Temperature {
private float value;
private String unit; // degree / Fahrenheit
public Temperature() {
}
public Temperature(float value, String unit) {
this.value = value;
this.unit = unit;
}
@Override
public String toString() {
return "Temperature [value=" + value + ", unit=" + unit + "]";
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.