Question

In: Computer Science

If you've ever opened your computer's device manager, you've likely seen a whole list of devices,...

If you've ever opened your computer's device manager, you've likely seen a whole list of devices, ranging from the obvious (keyboards, printers, monitors) to the internal (processors, memory, host controllers), to the subtle (network hosts, laptop lid closing, internal clock). While these devices can fall in a number of categories (input devices, graphics devices, audio devices, etc), they all share some features in common (they all have a name, a device driver, etc). In this section, we will design a very rudimentary implementation of a generic device driver. We are only interested in three things for the time being: the name of the device, an ID number identifying the device, and a flag indicating whether or not it is enabled. Thus, three fields are necessary, a String for the name, a int for the ID, and a boolean for the enabled status.

Any data elements should be declared private. If you think it is necessary you may include helper methods of your own. The class should implement the following public methods:

  • public Device(String name, int id) Initialize the device object with the given name and ID. Also, initially the device should not be enabled (the enabled flag should begin as false)
  • public final String getName() Retrieves the name of this device. This method is labelled final, meaning that future subclasses cannot change how it behaves.
  • public final int getID() Retrieves the ID of this device. This method is also final.
  • public String getCategory() Retrieves the specific category of this device, which should be the string "generic"
  • public void enable() Sets the state of the device to enabled.
  • public void disable() Sets the stae of the device to not enabled.
  • public boolean isEnabled() Retrieves the current state of the device.
  • @Override public String toString() Returns a string containing the category name, followed by the ID number, followed by a comma and the device name. For example, the followin would be an example of a valid output string: generic 0, x64 processor core

Solutions

Expert Solution

Device.java

public class Device {
   // Data members
   private String name;
   private int id;
   private boolean status;
   private String category = "generic";

   // Constructor to initialize data members
   public Device(String name, int id) {
       this.name = name;
       this.id = id;
       this.status = false;
   }

   // Getter method for name, id and category
   public final String getName() {
       return name;
   }

   public final int getID() {
       return id;
   }

   public String getCategory() {
       return category;
   }

   // Setter method for status
   public void enable() {
       status = true;
   }

   public void disable() {
       status = false;
   }

   // Getter method for status
   public boolean isEnabled() {
       return status;
   }

   // Return device details
   @Override
   public String toString() {
       return category + " " + id + ", " + name;
   }
}

DeviceTest.java

public class DeviceTest {

   public static void main(String[] args) {
       // Create device object and print it's details
       Device device = new Device("x64 processor core",0);
       System.out.println(device);
   }
}

OUTPUT


Related Solutions

Design your own degradative pathway. You know the rules(organic mechanisms), and you've seen the kinds of...
Design your own degradative pathway. You know the rules(organic mechanisms), and you've seen the kinds of reactions that occur in the biological degradation of fats and carbohydrates into acetyl CoA. If you were Mother nature, what series of steps would you use to degrade the amino acid serine into acetyl CoA? Need Help!!! PLEASE BE DETAILED IN YOUR ANSWER. THANK YOU.
Watch the TED talk by Hans Roling titled “The best stats you’ve ever seen”. You will need to include comments on this in your paper.
  Steps (all statistical analysis to be done in Excel and/or StatCrunch): Watch the TED talk by Hans Roling titled “The best stats you’ve ever seen”. You will need to include comments on this in your paper. Here is a link: http://www.ted.com/talks/hans_rosling_shows_the_best_stats_you_ve_ever_seen?language=en Download the Excel data from IvyLearn Create histograms of each of the variables (one histogram for fertility, one for life expectancy). Use the histograms to identify the shapes of the distribution. StatCrunch will be the easier tool to...
3- a) List and describe IN YOUR OWN WORDS the five functions of a manager?    ...
3- a) List and describe IN YOUR OWN WORDS the five functions of a manager?     b) How are financial statements used by business?     c) Compare variable and fixed expenses. USE YOUR OWN WORDS.
List all the steps that you as the project manager and your team will need to...
List all the steps that you as the project manager and your team will need to complete to get the CRM system developed and operational. The steps will include all the processes that must be accomplished as well as the subprocesses. Create a WBS to include the activities needed to implement a CRM system Explain the need and value for each task
List your responsibilities as a Software Development Project Manager, and explain how you measure the success...
List your responsibilities as a Software Development Project Manager, and explain how you measure the success and failure in any project? Give examples.
You are a mid-level procurement manager for your company. (You may choose one from the list...
You are a mid-level procurement manager for your company. (You may choose one from the list below.). Your department VP has called you in and given you a special assignment. The company is thinking of outsourcing the entire production of a group of non-core and lower-tier products. (It intends to maintain production of its “flagship” or core products and the most profitable parts of its product lines or product groups.) It is considering making this move, because the company has...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT