public class SensorClass{
// sensor details to recognize
private final String sensorID;
private final String sensorType;
private String sensorLocation;
private boolean sensorStatus;
// values to track
private double sensorCarbonValue;
private double wasteGenerated;
private double waterToxicity;
private double energyConsumption;
// constructor
public SensorClass(String sensorID, String sensorType, String sensorLocation, boolean sensorStatus, double sensorCarbonValue, double wasteGenerated, double waterToxicity, double energyConsumption){
this.sensorID = sensorID;
this.sensorType = sensorType;
this.sensorLocation = sensorLocation;
this.sensorStatus = sensorStatus;
this.sensorCarbonValue = sensorCarbonValue;
this.wasteGenerated = wasteGenerated;
this.waterToxicity = waterToxicity;
this.energyConsumption = energyConsumption;
}
public void displaySensorDetails() {
System.out.println("Sensor ID: " + sensorID);
System.out.println("Sensor Type: " + sensorType);
System.out.println("Sensor Location: " + sensorLocation);
System.out.println("Sensor Status: " + sensorStatus);
System.out.println("Sensor Carbon Value: " + sensorCarbonValue);
System.out.println("Waste Generated: " + wasteGenerated);
System.out.println("Water Toxicness: " + waterToxicity);
System.out.println("Energy Consumption: " + energyConsumption);
}
public void updateSensorValues(double carbonValue, double waste, double water, double energy) {
this.sensorCarbonValue = carbonValue;
this.wasteGenerated = waste;
this.waterToxicity = water;
this.energyConsumption = energy;
}
public void updateLocation(String location) {
this.sensorLocation = location;
}
public void updateStatus(boolean status) {
this.sensorStatus = status;
}
public double getCarbonValue(){
return sensorCarbonValue;
}
public double getWasteGenerated(){
return wasteGenerated;
}
public double getWaterToxicity(){
return waterToxicity;
}
public double getEnergyConsumption(){
return energyConsumption;
}
public static void main(String[] args) {
// Creating an instance of SensorClass
SensorClass sensor = new SensorClass("ID001", "Temperature Sensor", "Warehouse", true,
0.5, 200.0, 150.0, 300.0);
// Displaying sensor details
sensor.displaySensorDetails();
}
}