i’m doing a group project (the detail are in the picture) i got assign to do the
ID: 3717077 • Letter: I
Question
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. the temperature class should be base on the details in the picture. i only need you guys to make these TWO classes for me and that’s it 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. the temperature class should be base on the details in the picture. i only need you guys to make these TWO classes for me and that’s itExplanation / Answer
//-------------- 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.