Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

It has been a long time since I took the first part of this class and was able to find something similar elsewhere to figure

image text in transcribed

It has been a long time since I took the first part of this class and was able to find something similar elsewhere to figure out how it worked and tweak it to how I could understand and follow it for later. need help on this part have included the coding from last week as this needs to be added to that sorry the pictures are small I had tried putting the prompt pic. and copy of the code in the text but with the code that I had done it made it too long and I had to take so many spaces out it was hard to follow. editing to include what's already done in screenshote

image text in transcribedimage text in transcribedimage text in transcribed

Programming Assignment 2 - Smart Home continued You may have noticed that the Smart Home application we built in the last assignment was a little clumsy to implement. If we keep adding new devices, variables will be harder to track, and settings will be harder to manage. You may also notice that certain parts of the Smart Home could be grouped into different categories (for example, both the Music and Television devices shared audio settings). We could make our program more efficient and capable of growth by using inheritance. Object-oriented design to the rescue! Here are your program requirements for your revised Smart Home: . . . . . Create a parent class called "Device." This should have methods and variables to access and change the power status and the room they are located in Create Child Classes called "Entertainment, Appliance," "Security," and "Light." These should all inherit from "Device" Create Child Classes that inherit from "Entertainment" that include "Music" and "Television" Create Child Classes that inherit from "Appliance" that include "HVAC," "Oven," and "Refrigerator" Create Child Classes that inherit from "Security" that include "MotionSensor" and "Camera" Each class should have constructors and member variables. Keep variables private; only allow methods to access them Populate each class with relevant functionality (you can use Assignment 1 for some insight). Be sure to locate methods in the appropriate hierarchy. If functionality is common across all "Entertainment" devices (such as "change Volume()"), then put that in the "Entertainment" class. If something is unique to "Television," then put it in that class Instantiate at least one instance of the following in your main program: Light, Music, Television, HVAC, Oven, Refrigerator, MotionSensor, and Camera. This should be in a new file called "SmartHome2.java" As with the previous assignment, allow users the ability to input specific commands. You should have at least 12 distinct commands of your choosing; however, one of them should be "Help." When the user types "Help," have the system print out all commands for reference. Each command (except for "Help") should control one or more Smart Home devices. . 48 - 49 51 22+ import java.io.*; 24 25 public class Smart Home { 26 27 public static void main(String[] args) { 28 29 double temperature= 65; //house teng default 30 String acSetting; //will be ac or heat 31 boolean musicon= false; 32 String selectedSong = null; // user selected 33 boolean tvOn = false; //make this variable tvon 34 String selectedChannel= null; 35 String selectedLights []= {//creates array for light in each room 36 "bedroom", 37 "kitchen", 38 "living room", 39 "bathroom", 40 "garage" 41 }; 42 boolean lightson [] = {//create array to store light status for each room 43 false, //bedroom //all set to false by default 44 false, //kitchen 45 false, // Living room 46 false, //bathroom 47 false, //garage }; Scanner console= new Scanner(System.in); 50 System.out.println("Welcome home! What Would you like to do?"); while(true) {//creates loop to check for user command input 52 String command= console.nextLine();//to get new user commands 53 54 if (command.equals("Change temperature")) { //checks for temperature commands 55 System.out.println("What temperature would you like?"); 56 double newTemp= console.nextDouble(); 57 console.nextLine(); 58 59 if(temperature > newTemp) { 60 acSetting = "cool"; 61 System.out.println("A/C now set to " + acSetting); 62 temperature= newTemp; 63 64 }else if (temperature '9' || phoneNumber.charAt(i) newTemp) { 60 acSetting = "cool"; 61 System.out.println("A/C now set to " + acSetting); 62 temperature= newTemp; 63 64 }else if (temperature '9' || phoneNumber.charAt(i)

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

Students also viewed these Databases questions

Question

Why could the Robert Bosch approach make sense to the company?

Answered: 1 week ago