Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE MAKE THE 3 DIAGRAMS BELOW(take as much time needed): 1. 2. 3. BUILDING.JAVA package itec3030.assignments.a1; import itec3030.smarthome.standards.*; import java.util.ArrayList; public class Building {

PLEASE MAKE THE 3 DIAGRAMS BELOW(take as much time needed):
1.

Screenshot 2024-01-29 at 4.08.09 PM.png

2.

Screenshot 2024-01-29 at 4.08.16 PM.png

3.

Screenshot 2024-01-29 at 4.08.31 PM.png

BUILDING.JAVA

package itec3030.assignments.a1;

import itec3030.smarthome.standards.*;
import java.util.ArrayList;

public class Building {
    private ArrayList rooms = new ArrayList();
    private ICooler ac = null;
    private ITemperaturePreferenceSensor thermostat = null;

    public int getDesiredTemperature() {
        return thermostat.getReading();
    }


    public ICooler getCoolingDevice() {
        return ac;
    }

    public void setCoolingDevice(ICooler clr){
        this.ac = clr;
    }

    public ITemperaturePreferenceSensor getThermostat() {
        return thermostat;
    }

    public void setThermostat(ITemperaturePreferenceSensor sth){
        this.thermostat = sth;
    }

    public float getAvergeTemperature(){
        float count = 0, sum = 0;
        for (Room r : rooms){
            sum += r.getAvergeTemperature();
            count++;
        }
        return(float) (sum/count);
    }

    public Room findRoomOf(ISmartObject s){
        Room found = null;
        for (Room r : rooms){
            if (r.hasThing((ISmartObject) s))
                found = r;
        }
        return(found);
    }

    //
    // Install Constituent Rooms
    //

    public void add(Room room){
        rooms.add(room);
    }
}
 

ROOM.JAVA
package itec3030.assignments.a1;
import java.util.ArrayList;

import itec3030.smarthome.standards.*;

public class Room {
    private String name = "default";
    private ArrayList tempSensors = new ArrayList<>();


    public String getName() {
        return name;
    }
 

    public void setName(String name) {
        this.name = name;
    }

    //
    // ROOM SETUP
    //

    public void install(ITemperatureSensor t){
        tempSensors.add(t);
    }

    //
    // OFFER ROOM INFORMATION
    //


    public float getAvergeTemperature(){
        float count = 0;
        float sum = 0;
        for (ITemperatureSensor s : tempSensors){
            sum += s.getReading();
            count++;
        }
        return(float) (sum/count);
    }

    public boolean hasThing(ISmartObject s) {
        boolean found = false;
        for (ITemperatureSensor t :  tempSensors) {
            if (t.equals(s)) found = true;
        }
        // Collection of other types can be added here.
        return (found);
    }
}
 


CONTROLLER.JAVA
package itec3030.assignments.a1;

import itec3030.smarthome.standards.*;

/**
 *
 * @author Sotirios Liaskos
 */
public class Controller implements IController {

    /**
     * Reference to a building model.
     */
    protected Building house = new Building();

    /**
     * Set the building model which the Controller controls
     * @param bld
     */
    public void setBuildingModel(Building bld){
        house = bld;
    }

    /**
     * (See SSDCS documentation)
     */
    @Override
    public void changeDetected(ISmartObject s) {
        this.update();
    }

    private void update() {

        // See if you need to turn on heating
        if (house.getAvergeTemperature() > house.getDesiredTemperature() && !house.getCoolingDevice().isOn()) {
            System.out.println("Average house temperature is now: " + house.getAvergeTemperature() + " while desired is " + house.getDesiredTemperature() + ". Turning A/C on.");
            turnCoolingOn();
        }
        // See if you need to turn heating off
        if (house.getAvergeTemperature() <= house.getDesiredTemperature() && house.getCoolingDevice().isOn()) {
            System.out.println("Average house temperature is now: " + house.getAvergeTemperature() + " while desired is " + house.getDesiredTemperature() + ". Turning A/C off.");
            turnCoolingOff();
        }
    }

    private void turnCoolingOff(){
        house.getCoolingDevice().turnOff();
    }

    private void turnCoolingOn(){
        house.getCoolingDevice().turnOn();
    }

}


QUICKTHERMOSTAT.JAVA

package itec3030.assignments.a1;

import itec3030.smarthome.standards.*;

public class QuickThermostat implements INumericInstrument,ITemperaturePreferenceSensor {

    private int reading;

    @Override
    public int getReading() {
        return reading;
    }

    @Override
    public IController getController() {
        // No controller needed
        return null;
    }

    @Override
    public void setController(IController arg0) {
        // No need to set a controller
    }

    @Override
    public void newPreferredTemperature(int reading) {
        this.reading = reading;
    }
}
 

MAIN.JAVA
package itec3030.assignments.a1;

import itec3030.smarthome.standards.*;
import itec3030.assignments.a1.actuators.arcticcool.ArcticCoolFA15;
import itec3030.assignments.a1.sensors.omnitemp.OmniTempSensorXS3;


/**
 *
 * @author Sotirios Liaskos
 */
public class Main {
    Main p = new Main();

    public static void main(String[] args) {
        Controller c = new Controller();


        //Create Building
        Building h = new Building();
        Room livingRoom = new Room();
        Room bedRoom = new Room();
        livingRoom.setName("Living Room");
        bedRoom.setName("Bedoom");
        h.add(livingRoom);
        h.add(bedRoom);

        //Create the sensors
        ITemperatureSensor o1 = new OmniTempSensorXS3(c,"o1");
        ITemperatureSensor o2 = new OmniTempSensorXS3(c,"o2");
        ITemperatureSensor o3 = new OmniTempSensorXS3(c,"o3");
        ICooler ac = new ArcticCoolFA15("ac");
        ITemperaturePreferenceSensor th = new QuickThermostat();

        //"Install the sensors in the rooms
        livingRoom.install(o1);
        livingRoom.install(o2);
        bedRoom.install(o3);

        //Thermostat and AC go in the building not individual rooms
        h.setCoolingDevice(ac);
        h.setThermostat(th);
        //The controller needs access to the building model (to acquire temperature info etc.)
        c.setBuildingModel(h);

        //Scenario starts with the A/C running.
        ac.powerOn();
        //The Scenario object simulates the sensing hardware and sends a number of values to the sensor drivers o1 - o3
        // and the thermostat (how? - look at the SSDCS spec!) according to a random pattern (which you
        // are not supposed to reverse engineer!).
        Scenario e = new Scenario(o1,o2,o3,th);
        e.play();
        ac.powerOff();
    }
}


ABSTRACTOMNIREMPSENSOR

  
 


 
  

OMNITEMPSENSORXS3

Screenshot 2024-01-29 at 4.21.58 PM.png   

ABSTRACTARCTICCOOL

Screenshot 2024-01-29 at 4.23.01 PM.png

     

ARCTICCOOLFA15

Screenshot 2024-01-29 at 4.19.37 PM.png

    

ASSIGNMENT OVERVIEW:
 

Screenshot 2024-01-29 at 4.25.35 PM.png 

Develop a sequence diagram, describing how all pertinent classes (including those of the vendors) collaborate in a scenario in which the temperature has changed in a way that the a/c needs to be turned on. For simplicity, please consider only the most concrete classes in the collaboration (not abstract classes or interfaces).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Algorithms questions

Question

What is allocation? Discuss in detail.

Answered: 1 week ago

Question

Explain why there is no value L for which lim x sin x = L.

Answered: 1 week ago

Question

What are the challenges associated with tunneling in urban areas?

Answered: 1 week ago

Question

What are the main differences between rigid and flexible pavements?

Answered: 1 week ago

Question

What is the purpose of a retaining wall, and how is it designed?

Answered: 1 week ago

Question

How do you determine the load-bearing capacity of a soil?

Answered: 1 week ago

Question

what is Edward Lemieux effect / Anomeric effect ?

Answered: 1 week ago

Question

What are the qualities the character hides from themselves?

Answered: 1 week ago

Question

What would they find most embarrassing if people knew?

Answered: 1 week ago