Details of this Paper





Thank you!!;Q-1 ANSWER;When we perform a task in Java, it is housed in the method. When we perform the methods, it is housed in the program unit named a class (Dietel&Dietel, 2012). By defining the tasks performed in the method we define the class (Dietel&Dietel, 2012). It becomes an instance of the class or instantiation (Dietel&Dietel, 2012). The use of the class system and various methods allows the Java programmer to take a much larger project and break it down into smaller code-able pieces.;In reviewing my room and creating a class, it was necessary to look at the tasks or methods that need completing. The first class would be the dishes. The first method housed in that class would be washing the dishes. The second method would be drying the dishes. And the third method would be storing the dishes away or for our purposes removing the dishes.;The fields would be data type public integer;//The Dishes Class has three fields;publicint cups;publicint plates;publicint silverware;The word public shows that each of these fields will be public and available to any object within the class (Dietel&Dietel, 2012). And the int identifies that the data type is integer which is one of the primitive data types (Lowe, 2014). This data type was chosen because there can only be whole numbers of cups, plates and silverware. And then finally the fields name which is cups, plates, and silverware. The attributes of these integer fields would be to count the dishes or cups = 10, plates = 5, and silverware = 50.;The fields used in the methods would be;publicbooleanwashingDishes;publicbooleandryingDishes;publicbooleanremovingDishes;In choosing these names, the methods must be a verb for Java (Dietel&Dietel, 2012). In this case, it is the different actions that would be required with the dishes. Again, the modifier is public and the data type is boolean. This data type was chosen because we only want to know when the job is completed. To do that we will use the boolean data type to respond with a value that is true or false. The methods will require parameters because we want to specify how to accomplish the true and false and these can be found within the parenthesis (Dietel&Dietel, 2012).;// Dishes Class washingDishes method;publicbooleanwashingDishes (Boolean clean, Boolean dirty);return (clean | | dirty);// Dishes Class dryingDishes method;publicbooleandryingDishes (Boolean wet, Boolean dry);return (wet | | dry);// Dishes Class removingDishes method;publicbooleanremovingDishes (Boolean yes, Boolean no);return (yes | | no);The first application that would utilize the class could be making sure that the dishes are washed, dried, and stored daily. This would prevent the need to go behind the children to see if they have completed their chores. The system could state whether all three methods had been completed, whether they have been completed each day, and send an email if these tasks have not been completed by 8pm.;The second application that could utilize this class would be if the methods returned false, meaning they have not been used in two days, that they system would shut down the equipment assuming the family was away thereby saving the family money.;Your opinion;Q-2 ANSWER;Considering the entities in my bedroom, I will develop a class using my alarm clock. My alarm clock class will look like the following;Clock;CurrentTime: Date;AlarmTime: Date;SnoozeTime: Minutes;setAlarm (): Date;setSnooze (NumberofMinutes: Minutes);I decide on the above data types base on the attributes presented in the class. Since the current and alarm time will be a date, it is best to use the date data type to display the information correctly. For the SnoozeTime attribute, using the minutes data type will best fit due to the fact that the snooze time is the number of minutes one will like the alarm clock to alarm again after the snooze button is press.;The type of applications that might be able to use my class will be one that centralizes the management of appliances in a home. For instance, if you have an application that control the stove or microwave timer, then this class will be perfect. You can set the alarm on the stove to signal an alarm at a certain time and the same goes for the microwave, which already uses an instance of this class. Any application that uses a clock will be able to use this class.;I will require a parameter in my setSnooze method as indicated in the class diagram. The reason for wanting to use a parameter is to provide the clock with additional information such as the number of minutes, the number of minutes will determine how long the clock should snooze before it alarms again. Although it is not indicated, it will be wise to require a parameter for the setAlarm method. It will ensure that the date information for the alarm clock is inputted. However, there are many instances were alarm will not be set, for example, on non-working days.;------------------------------------------------------------------------------------------------------------------------------------------ Your opinion;Q-3 ANSWER;In Java a class is a type of category, like the category of all items in this room or the category of all the objects in my room are printers and computer. (Lowe, 2014). If I were to create a class that defined my room and some of the attributes of it, the class would look like this;//My Room and some of the amenities;Public Class MyRoom;IntNumOfPrinters;IntNumOfComputers;Boolean PrinterOn = true;Boolean ComputerOn = true;This Java code defines the class as MyRoom and it has an integer representative of the number of printers and computers. The Java code also uses a data type of Boolean to turn on or turn off the Printers and Computers in my room.;//Example of integers code for number of printers & computers;Public MyRoom;NumOfLamps = 2;NumOfTelevisions = 3;//Example of Boolean data type to show that the Printer & Computer are on;public void setPrinter(Boolean a);PrinterOn = a;public void setComputer(Boolean a);ComputerOn = a;I could also set the Clock to read and send a message if I am hungry or not. If the time is 12:00 PM, then the display will read ?It?s time to eat!? If the time not 12:00 PM, then the message displayed will read ?You are Not Hungry!?;Public Class MyRoom;Public int time;if (time = 12:00 PM;System.out.println("It?s time to eat!");else;System.out.println("You are Not Hungry!");------------------------------------------------------------------------------------------------------------------------------------------;Your Opinion


Paper#68147 | Written in 18-Jul-2015

Price : $27