Question: Class Design involving 2d arrays and overloading. Write a simple Device class with a few features that could be used to compare Device instances and
Class Design involving 2d arrays and overloading.
Write a simple Device class with a few features that could be used to compare Device instances and a Driver class with which to test/drive this Device class.
Skills Expected
Multi-dimensional array
Constructor and method overloading
Assignment Description
You will create two Class objects (and subsequently submit two .java files)
Device
Driver
Notes:
ONLY the Driver Class should have static methods.
The Device Class should NOT have static methods or static instance variables (constants ok).
The below is the minimum you must include you could include additional instance variables, methods, etc. as you need. Class Design: Device The Device class is intended to be an abstract and simplified representation of a device. Each device will have a multi-dimensional array of features which contain the feature name (e.g. Storage Size) in one row and the feature data (e.g. 64GB) in another row.
Data to store
Device name
o Make this a private instance with a public getter and setter
Features List (e.g. String[][])
o Make this a private instance with no getter and setter Available actions
[2 Points] Constructor
o Take in as argument the device name (enforce invariants)
o Initialize the features list to have at least 10 columns and two rows
[2 Points] Overloaded Constructor
o Take in as argument the device name as well as features list (enforce invariants)
[2 Points] Add Feature
o Take in as argument the feature name and value and
If the feature name is NOT already in the list of features, add both the name and value to the list of features
If the feature name is already in the list of features, update the value to include the previous value as well as the new value.
[2 Points] Get Feature Value
o Take in as argument a feature name and return the value associated with the feature if found. Return Feature not found as appropriate
. [2 Points] Get Feature Value
o Take in as argument an index value and return the value associated with feature for the given index. Be sure to check for invariants
. [2 Points] Show Features
o Print out a table of features for the current Device instance.
Class Design: Driver
Positive testing (checking for valid conditions)
o [1 Point] Create a Device with only device name
o [1 Point] Create a Device with both a device name as well as a feature list
o [1 Point] Add at least three new features (with different values) to all device instances
o [1 Point] Get a feature value based on the feature name
o [1 Point] Get a feature value based on the index
o [1 Point] Print out the list of features
Negative testing (checking for invalid conditions)
o [1 Point] Attempt to create a Device with invalid device name (e.g. empty string)
o [1 Point] Attempt to create a Device with invalid device name and/or feature list
o [1 Point] Attempt to add a feature that has already been added to the feature list
o [1 Point] Attempt to get the value for a feature not in the feature list
o [1 Point] Attempt to get the value for a feature given an invalid index (e.g. -1)
Boundary testing
o [1 Point] Attempt to create a Device with a feature list that is exactly at capacity
o [1 Point] Attempt to create a Device with a feature list that exceeds capacity (e.g. 11 columns)
o [1 Point] Attempt to add a feature with invalid name/value
o [1 Point] Attempt to show features when the feature list has nothing in it yet
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
