Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ISM3230 In-class lab 8 Spring 2017 TOPIC: Introduction to classes Attributes, methods In Lab 6 we modeled a situation where we needed to keep track

image text in transcribedimage text in transcribedimage text in transcribed

ISM3230 In-class lab 8 Spring 2017 TOPIC: Introduction to classes Attributes, methods In Lab 6 we modeled a situation where we needed to keep track of servers in a server farm. Each server could be on or off, and we used a boolean array to store the server state. Now imagine you want to keep track of additional variables pertaining to each server, such as temperature, load, operating system, server id, etc. To do this, we would need another array of doubles for temperature, another one for load, while to keep track of server ids and operating system we would need two additional String arrays. All these arrays are logically related as they keep related server data but in the code there is no way to indicate this relationship and they appear as independent arrays. With an object-oriented approach, we can keep all the related data (and functionality) together and organize it in terms of classes, objects, properties, and methods. TASK/ INSTRUCTIONS Create a Server class that holds data and functionality belonging to an individual computer, such as a server ID and running status. Then create a Farm class that holds data and functionality about one server farm (farm is a collection of servers located in one place). Finally, create a driver program in which you instantiate one farm object and set the farm's properties. In the driver you then create 20 running server instances and assign them to the farm. You print the farm's summary information, turn off 4 servers, print farm info, turn off additional server, and print farm info one more time. Finally, you print the ID of the last server that was assigned to the farm Follow the instructions below: 1) class Server and its objects will keep track of individual server ID strings (such as "RB_150_1") and the running status of that server (a boolean true for running, false for stopped). The server objects can also report their status as a character (for printing purposes): they report 'o' for running, and 'x' for stopped. The class Server has the following a) public attributes: i) String serverlD for storing the ID string of the server boolean serverStatus for storing the running state of the server (true for running, false for stopped) i) b) public methods i) reportStatusAs Char ( returns an ' o ' character when the server is running, char or an 'x' character when the server is stopped. Hint: This character value is returned from the method, it is not printed ISM3230 In-class lab 8 Spring 2017 TOPIC: Introduction to classes Attributes, methods In Lab 6 we modeled a situation where we needed to keep track of servers in a server farm. Each server could be on or off, and we used a boolean array to store the server state. Now imagine you want to keep track of additional variables pertaining to each server, such as temperature, load, operating system, server id, etc. To do this, we would need another array of doubles for temperature, another one for load, while to keep track of server ids and operating system we would need two additional String arrays. All these arrays are logically related as they keep related server data but in the code there is no way to indicate this relationship and they appear as independent arrays. With an object-oriented approach, we can keep all the related data (and functionality) together and organize it in terms of classes, objects, properties, and methods. TASK/ INSTRUCTIONS Create a Server class that holds data and functionality belonging to an individual computer, such as a server ID and running status. Then create a Farm class that holds data and functionality about one server farm (farm is a collection of servers located in one place). Finally, create a driver program in which you instantiate one farm object and set the farm's properties. In the driver you then create 20 running server instances and assign them to the farm. You print the farm's summary information, turn off 4 servers, print farm info, turn off additional server, and print farm info one more time. Finally, you print the ID of the last server that was assigned to the farm Follow the instructions below: 1) class Server and its objects will keep track of individual server ID strings (such as "RB_150_1") and the running status of that server (a boolean true for running, false for stopped). The server objects can also report their status as a character (for printing purposes): they report 'o' for running, and 'x' for stopped. The class Server has the following a) public attributes: i) String serverlD for storing the ID string of the server boolean serverStatus for storing the running state of the server (true for running, false for stopped) i) b) public methods i) reportStatusAs Char ( returns an ' o ' character when the server is running, char or an 'x' character when the server is stopped. Hint: This character value is returned from the method, it is not printed

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

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

0130913677, 978-0130913678

More Books

Students also viewed these Databases questions

Question

What is the dew-point temperature?

Answered: 1 week ago