Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

// Part 2 Scenario e = new Scenario (01, 02, 03, 04); e.play(); // Part 3 uncomment to execute th = new ThermosetX19(); h.setThermostat

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

// Part 2 Scenario e = new Scenario (01, 02, 03, 04); e.play(); // Part 3 uncomment to execute th = new ThermosetX19(); h.setThermostat (th); e = new Scenario (01, 02, 03, 04); e.play(); public float getAverge Temperature () { float count = 0; float sum = 0; for ( } } } s tempSensors) { sum +=s.getReading(); count++; return(float) (sum/count); /** * Returns true if an object implementing a SmartThing interface is found in the room. * @param s Reference to an objects that implements SmartThing. * @return True if the Thing is installed in the room. Currently checks only the collection of temperature sensors. */ public boolean hasThing(_ boolean found = false; for (_____ s) { t: tempSensors) { if (t.equals(s)) found = true; } // Collection of other types can be added here. return (found); public class Main { Main p = new Main(); /** * @param_args the command line arguments */ public static void main(String[] args) { Controller c = new Controller(); //Create Building Building h = new Building(); Room Living Room = new Room(); Room bedRoom = new Room(); living Room.setName("Living Room"); bedRoom.setName("Bedoom"); h.add(living Room); h.add(bedRoom); Temperature Sensor o1 = new OmniTemp SensorXS3 (c, "01"); Temperature Sensor 02 = new OmniTempSensorXS3 (c, "02"); Temperature Sensor 03 = new OmniTemp SensorXS3 (c,"03"); Temperature Sensor 04 = new OmniTemp SensorXS3 (c,"04"); Furnace f = new SaharaFurnaceHL42("f"); Numeric Measurement Instrument th = new QuickThermostat (); living Room.install (01); living Room.install (02); bedRoom.install (03); bedRoom.install(04); h. setFurnace (f); h.setThermostat (th); c.setBuilding Model (h); -/** * * @author Sotirios */ public class Controller implements Controller Interface { } /** * */ protected Building house = new Building(); /** * * @param bld */ public void setBuilding Model (Building bld) { house = bld; } /** * */ public void update() { // See if you need to turn on the furnace if (house.getAverge Temperature () < house.getDesired Temperature () && ! .().ison()) { System.out.println("Average House Temperature is now: + house.getAverge Temperature() + ". Turning heating on."); turnHeatingOn (); } } // See if you need to turn on the furnace if (house.getAverge Temperature() >= house.getDesired Temperature () && _().ison()) { System.out.println("Average House Temperature is now: + house.getAverge Temperature() + ". Turning heating off."); } turnHeatingOff(); private void turnHeatingOff() { private void turnHeatingOn () { @Override public void changeDetected (_ s) { this.update(); } import itec3030.smarthome.standards. /** * A Room object for maintaining room information. * @author Sotirios public class Room { private String name = "default"; private ArrayList /** * A Room object for maintaining information about the entire building. * @author Sotirios */ public class Building { H A + private ArrayList rooms = new ArrayList (); private furnace = null; private Numeric Measurement Instrument thermostat = null; /** * Returns the temperature desired by the inhabitants of the building. * @return The desired temperature. public int getDesired Temperature() { return thermostat.. /** * Returns a reference to the furnace installed in the building. * @return A reference to the furnace installed in the building. */ public getFurnace() { return furnace; } /** * "Installs" a furnace in the building. .0; } * @param frn A reference to the furnace to be installed in the building. */ public void setFurnace(___. frn) { furnace = frn; } /** * Returns a reference to the thermostat installed in the building. * @return A reference to the thermostat installed in the building. */ public Numeric Measurement Instrument get Thermostat() { return thermostat; } /** * "Installs" the thermostat in the building * @param sth Reference to a things that performs numeric measurements. */ public void setThermostat (Numeric Measurement Instrument sth) { this.thermostat = sth; } /** * Returns the average temperature in all rooms of the building. * @return Average temperature over all rooms of the building. */ public float getAverge Temperature () { float count = 0, sum = 0; for (Room r: rooms) { } } } sum += r.getAverge Temperature (); count++; return(float) (sum/count); /** * Locates and returns the room in which a SmartThing is installed. * @param s Reference to a SmartThing. * @return Reference to the Room in which the SmartThing is installed. */ public Room findRoomOf(. Room found = null; for (Room r rooms) { if (r.hasThing ((__ found = r; } return(found); _// // Install Constituent Rooms // s) { _) s)) /** * Add a room to the building. * @param room Reference to a Room Object. */ public void add (Room room) { rooms.add(room); } Create a ComplexNumber class to represent a complex number. A complex number is a number that's of the form a+bi, where a and b are real numbers (a, b = R), but i -1, also called the imaginary unit. Check Wikipedia if you need a refresher. 1 The fields for a ComplexNumber should be a and b, . Create a constructor that initializes values for both a and b. You do not need a variable to represent i, the imaginary unit. Create instance methods add, subtract, multiply, and divide. Each of these methods will take in one other ComplexNumber and performs the stated operation to produce a new ComplexNumber. For example, the add method should look like this: public Complex Number add (Complex Number other) { Demo by creating some complex numbers and testing them out. Yes Terminate Server Initialize Await Upcoming Connections Client connected Create Client Thread Send Current Directory Info Await Client Command Client Sends Command Client Terminated? No Execute Client Command Yes Client Initialize Terminate Connect to Server Display Current Directory Info to User Server responds with current directory Await User Command No User enters command Command is "exit"? Send Command to Server executes Server command The apartment also has an SSDCS-compliant Forced-Air Furnace by a very well reputed brand called Sahara GmbH. The specific model used is SaharaFurnaceHL42 and the driver can be found on eClass (ClassLibrary-Furnace.jar) and documentation here. The developers of "Smart Builders" have developed some starter code as follows: Room.java, which they use to model the room, as well as keep track of all the devices that are installed there. The code unfortunately is missing some key parts. Your job is to put together the java files and the libraries in e.g., an IntelliJ/Eclipse project, complete the missing parts. Exercise 3 Building.java, which is a collection of Rooms and also includes the furnace. Controller.java, which models the controller device which collects data from sensors and sends commands to actuators via the Room, building classes, depending on where the devices are installed. (*NEW*) QuickThermostat.java, which is a stub of a thermostat for running Exercise 2. Assume now that you are the company that develops thermostats, called ThermoSet Ltd. In this assignment, thermostats are devices that allow building habitants set their desired temperature. SSDCS has an interface for those. ThermoSet's thermostat, ThermoSetX19, must therefore implement that interfaces. It also needs to implement a predefined front end. You need to do the following: Main.java, in which the apartment in question is built. You will also need to this Scenario.jar plug-in. Your solution should operate under any scenario provided by the instructor. Download this GUI plug-in from eClass (ThermostatFrontEnd.jar) and study its Java doc here. Implement SSDCS-compliant thermostat ThermoSetX19 and plug the above GUI in it. Develop its documentation Using JavaDoc. Once this is done help "Smart Builders" incorporate the ThermoSetX19 in their design. Update their code and submit updated result. Smart Home Controller In this assignment you will work on developing a Smart Home controller. The Controller receives data and notifications from several sensors spread around a building, and based on these it controls several actuators, i.e., devices that change the state of the house. A major challenge is integrating various devices from different vendors so that they all work together with the controller. Sensors. Sensors are objects that collect information from the environment. In our case these will be Temperature Sensors and a Thermostat, i.e., a device that lets users define the desired temperature. Sensors, Controllers and Actuators of various vendors are able to work together through the use of Interfaces. Specifically, a consortium of smart home vendors, called "ITEC3030 Smart Home Consortium" worked together to produce the Simple Smart Device Collaboration Standard (SSDCS) in form of a set of Java Interfaces. Actuators. Actuators are objects that can perform changes in the environment. In our case these are a Furnace. Controller. A controller is a device which receives events and data from Sensors and issues commands to the Actuators based on hardcoded logic. The Interfaces can be downloaded from eClass (Standards.jar) and the JavaDoc-generated Documentation can be found here. For this assignment you will need to complete the following exercises: Exercise 1 Study the documentation of the SSDCS. Use draw.io to generate a class diagram that describes the SSDCS as documented. Exercise 2 A Smart Home installations contractor "Smart Builders" needs to put together a smart apartment using a Controller that they build. The apartment consists of two rooms: A Living Room, which contains two sensors OmniTempSensorXS3 by OmniTemp Inc. A Bedroom, which contains another two OmniTempSensorXS3 by the same brand. An SSDCS-compliant driver for OmniTempSensorXS3 can be found on eClass (ClassLibrary- TempSensor.jar) and documentation here. Given the software system described in the Course Project, your goal for this assignment is to come up with test cases for the command parsing and validation portion of the software. For the create command: Think of examples of valid commands. Think of examples of invalid commands. For each test case you think of, state the case and the expected outcome. What edge cases can you think of? For the deposit command: Think of examples of valid commands. Think of examples of invalid commands. For each test case you think of, state the case and the expected outcome. What edge cases can you think of? You should update your code for Lab 4C with the following changes: If the user does not choose option 4 (Exit the Program), the program should keep running until they choose this option. Add "error handling" to the option input prompt. If the user does not enter a valid option, notify them and then ask for new input. Do not let them proceed until they've entered a valid option. . There should be a new option (-1) that lets you change the number that will be operated on. Do not display option 1 (Get the reciprocal of the number) if the number that will be operated on is 0. Call the file name Assignment4B(.java, .cs, .cpp) and the class name Assignment4B. User input is indicated in bold. (Note: Depending on your programming language, whole numbers may or may not have the decimal value shown. Do not try to add this manually if your language doesn't show the decimal). Sample Output: Welcome! Please input a number: 100 What would you like to do to this number: -1- Re-enter the number 0 Get the additive inverse of the number 1- Get the reciprocal of the number 2- Square the number 3- Cube the number 4- Exit the program 2 The square of 100.0 is 10000.0 What would you like to do to this number: -1- Re-enter the number 0- Get the additive inverse of the number 1- Get the reciprocal of the number 2- Square the number 3- Cube the number 4- Exit the program -1 Please input a number: 0 What would you like to do to this number: -1- Re-enter the number 0- Get the additive inverse of the number 2- Square the number. 3- Cube the number 4- Exit the program 7 Please enter a valid number between 1 and 4: 12 Please enter a valid number between 1 and 4: -1 Please input a number: 24 What would you like to do to this number: -1- Re-enter the number 0- Get the additive inverse of the number 1- Get the reciprocal of the number 2- Square the number. 3- Cube the number 4- Exit the program 4 Assignment4C: Backspacing Animation. We covered special characters like and \t in a prior module. We also mentioned \b, which replicates the backspace command and "erases" the preceding character when printed to the screen. We're going to use the behavior (along with loops and a new pause command) to make a short animation of a string being erased via backspacing. For this assignment, you will prompt the user for a sentence. You will also ask them how many letters they want to "erase" with backspacing. You will print the full sentence to the screen (with no newline character added). Then, you will use a loop to print the \b character the specified number of times. After printing each \b character, you should use also use the sleep command inside the loop to pause the program for half a second. Information on how to do this are included in the Appendix at the end of the instructions. Call the file name Assignment4C (.java, .cs, .cpp) and the class name Assignment4C. Example output is shown below. Note that the last line is the final output-your code's output should gradually remove a letter every half-second until it ends up the same as the final output. User input is indicated in bold. Sample Output: [Backspace Animation] Please enter your sentence: Welcome to CSE 1321L! How many letters do you want to backspace? 14 Welcome Submission: 1. You will submit 3 separate files, one for each of the assignments above. 2. File names and class names must be correct. 3. Upload all 3 files (simultaneously) to the assignment submission folder in Gradescope. 4. We'll continue to work with you on this assignment if something messes up, so long as you submit by the due date. However, start early because we work during the weekday. CSE 1321L: Programming and Problem Solving I Lab Assignment 4 - 100 points Iteration What students will learn: 1) Problem solving 2) Using loops 3) Using logic within loops 4) Nested loops (loops inside of loops) Overview: If there's one thing that computers do well, it's repeating things. In fact, most of what your computer does is simply "loop" waiting for some kind of input. For this assignment, you're going to use loops to solve some basic problems, and we hope you have fun while you're doing it. The programs aren't long but will require you to think critically. Again, start early, practice, and ask a lot of questions. Follow the same conventions for class names and file names for your source code. For the Java folks, remove the "package" statement if you have one. Make sure to follow the FYE Submission Guidelines. Finally, we don't mean to lecture, but we want to remind you not to cheat. This is the core of what a lot of you will be doing for a living, so master it now. Assignment4A: Where will we go? The College of Computing and Software Engineering is trying to decide what country next year's study abroad program will take place in. The initial list has four countries: Italy Costa Rica Pax Bisonica Ghana The college emailed out a survey to all students, but no one responded. They have now tasked you with asking every student's opinion directly. You will create a program that allows you to record each student's response. Since you don't know how many people you'll talk to, you should use a non-deterministic loop that stops based on a sentinel value. Assume that all answers are entered correctly and exactly as shown Once you tell the loop to stop, it should print out the totals for each country and let you know which one was the winner. Call the file Assignment4A (.java, .cs, .cpp) and the class name Assignment4A. The following sample output shows one example of the programming running. User input is indicated in bold. Sample Output: [CCSE Study Abroad Survey] Student #1: Which country should we go to for our next study abroad program? Italy AN Costa Rica P Pax Bisonica Ghana (Type Quit to end the survey) Ghana Thank you! Student #2: Which country should we go to for our next study abroad program? Italy Costa Rica Pax Bisonical Ghana (Type Quit to end the survey) Pax Bisonica Thank you! //Skipping ahead (don't print this line!) Student # 122: Which country should we go to for our next study abroad program? Italy Costa Rica Pax Bisonical Ghana (Type Quit to end the survey) Quit [Results] Italy: 20 Costa Rica: 34 Pax Bisonica: 35 Ghana: 32 Next year's study abroad program will take place in Pax Bisonica. Assignment4B: Updating Lab 4C. One of the most common tasks for programmers is going back and working on older programs, also known as "legacy code". This can be for many reasons - it may need to be updated due to changes in the market or other software, or you may need to add new features. In this assignment, you'll have a gentle introduction to working with legacy code by updating Lab 4C with the new looping structures we've learned. Appendix Making the program "pause" is an advanced topic that will be covered in more detail in CSE 1322. For now, you just need to know how to implement the code in your program. The following code samples will show you how to do this. Note that you will be running these commands more than once - consider what looping structures you've learned in this module that you could use to do this. The relevant parts are highlighted. Java public class Assignment4C { } public static void main(String[] args) throws InterruptedException { } } C# class Assignment4C { //Pause the program for 0.5 seconds Thread.sleep(500); public static void Main(string[] args) { } C++ //Pause the program for 0.5 seconds System.Threading.Thread.Sleep(500); //Note: You may need to use "\b \b" rather than just "\b" #include int main() { //Pause the program for 0.5 seconds usleep(500000); //Makes the changes appear in the console cout.flush(); //Note: You may need to use "\b \b" rather than just "\b" }

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_2

Step: 3

blur-text-image_3

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

Exploring Management

Authors: John R. Schermerhorn

3rd edition

1118217252, 9780470878217, 978-1118217252

More Books

Students explore these related Programming questions