

![Class Design: Driver Positive testing (checking for valid conditions) o [1 Point] Create a Device with only device name o](http://img.homeworklib.com/images/c32d54b3-1069-4b6c-b480-dddbdc612187.png?x-oss-process=image/resize,w_560)
In Java PLS
Thanks for the question.
Here is the completed code for this problem. Let me know if you
have any doubts or if you need anything to change.
Thank You !!
================================================================================================
public class Device {
private String deviceName;
private String[][] features;
private int featureCount;
public Device(String deviceName) {
setDeviceName(deviceName);
features = new String[2][10];
featureCount = 0;
}
public String getDeviceName() {
return deviceName;
}
public void setDeviceName(String deviceName) {
if (deviceName == null || deviceName.trim().length() == 0) {
throw new IllegalArgumentException("Device Name cannot be null or empty");
}
this.deviceName = deviceName;
}
public void addFeature(String featureName, String featureValue) {
if (featureName == null || featureName.trim().length() == 0) {
System.out.println("Invalid feature name.");
return;
}
if (featureCount < 10) {
// check if the feature exists
for (int col = 0; col < featureCount; col++) {
if (features[0][col].equalsIgnoreCase(featureName)) {
features[1][featureCount] = featureName;
return;
}
}
// if feature dont exist add a new entry
features[0][featureCount] = featureName;
features[1][featureCount] = featureValue;
featureCount += 1;
}
}
public String getFeatureValue(String featureName) {
if (featureName == null || featureName.trim().length() == 0) {
System.out.println("Invalid feature name.");
return "Feature not found";
}
for (int col = 0; col < featureCount; col++) {
if (features[0][col].equals(featureName)) {
return features[1][col];
}
}
return "Feature not found";
}
public String getFeatureValue(int index) {
if (index < 1 || index > featureCount) {
return "Feature not found";
}
return features[1][index - 1];
}
public void showFeatures() {
System.out.println("Device Name: " + getDeviceName());
if (featureCount == 0) {
System.out.println("No Feature exist.");
return;
}
System.out.println(String.format("%-15s%15s", "Feature Name", "Feature Value"));
for (int col = 0; col < featureCount; col++) {
System.out.println(String.format("%-15s%15s", features[0][col], features[1][col]));
}
}
}
================================================================================================
public class DeviceDriver {
public static void main(String[] args) {
Device dell = new Device("Dell");
Device hp = new Device("HP");
hp.addFeature("RAM","8GB");
hp.addFeature("Hard Disk","1024 GB");
hp.addFeature("Processor","Quad Core");
System.out.println("HP Hard Disk Value: "+hp.getFeatureValue("Hard Disk"));
System.out.println("HP Feature at index 3: "+hp.getFeatureValue(3));
hp.showFeatures();
try{
Device lenevo = new Device("");
}catch (IllegalArgumentException exception){
System.out.println(exception.getMessage());
}
// feature all exist
hp.addFeature("RAM","16GB");
System.out.println("HP RAM Value: "+hp.getFeatureValue("RAM"));
// feaure dont exist
System.out.println("HP Operating System Value: "+hp.getFeatureValue("OS"));
// negative index -1
System.out.println("HP Feature at index -1: "+hp.getFeatureValue(-1));
// boundary
hp.addFeature("Feature 4","Feature Value 4");
hp.addFeature("Feature 5","Feature Value 5");
hp.addFeature("Feature 6","Feature Value 6");
hp.addFeature("Feature 7","Feature Value 7");
hp.addFeature("Feature 8","Feature Value 8");
hp.addFeature("Feature 9","Feature Value 9");
hp.addFeature("Feature 10","Feature Value 10");
hp.showFeatures();
// one more feature
hp.addFeature("Feature 11","Feature Value 11");
hp.showFeatures();
// negative testing
hp.addFeature(null,"Null Value");
dell.showFeatures();
}
}
================================================================================================


thanks !
In Java PLS HW7: Feature Comparison CSS 142 Computer Programming 1 By: Hansel Ong Summary With so many options for most...
USING JAVA,
Class Design: Person The Person class is intended to be an abstract and simplified representation of a person. Each person will have an array of "friends" - which are other "Person" instances. Data to Store (2 Points) Name private instance variable with only private setter (2 Points) Friends private instance array with neither getter nor setter Actions Constructor o 1 Point) Take in as argument the name of the person (enforce invariants) o (1 Point) Initialize the array...
In Java Pls
Class Design: Donut (Suggested Time Spent: < 15 minutes) The Donut class is intended to be an abstract and simplified representation of a yummy edible donut Class Properties (MUST be private) Name of the donut Type of donut Price of the donut Class Invariants Donut name must not be empty (Default: "Classic") Type of donut can only be one of the following: "Plain," "Filled," or "Glazed" (Default: "Plain") Class Components Public Getter and Private Setter for name,...
In Java Code Needed is Below the Question Using Program 3: Encapsulating Dogs, modify this program to create a database of dogs of your own. You will also include File I/O with this program. You will create 3 classes for this assignment. The first class: Create a Class representing the information that is associated with one item (one dog) of your database. Name this class Dog. Using Lab 3, this will include the information in regard to one dog. The...
The following is for java programming. the classes
money date and array list are so I are are pre made to help with
the coding so you can resuse them where applicable
Question 3. (10 marks) Here are three incomplete Java classes that model students, staff, and faculty members at a university class Student [ private String lastName; private String firstName; private Address address; private String degreeProgram; private IDNumber studentNumber; // Constructors and methods omitted. class Staff private String lastName;...
All commands must be in the command line. The expense data file is separate. Programming Project #2: Manage Spending Using Commands Objectives: • Understand how to create and manipulate list of objects using array or vector class • Handle input errors and invalid values • Design and create a well-structure program using C++ basic programming constructs and classes. Description: Each “expense” contains 2 values: the spending amount (double) and its description (string) Here is an example of the “expense” data...
Amusement Park Programming Project Project Outcomes Use the Java selection constructs (if and if else). Use the Java iteration constructs (while, do, for). Use Boolean variables and expressions to control iterations. Use arrays or ArrayList for storing objects. Proper design techniques. Project Requirements Your job is to implement a simple amusement park information system that keeps track of admission tickets and merchandise in the gift shop. The information system consists of three classes including a class to model tickets, a...
***JAVA: Please make "Thing" movies.
Objective In this assignment, you are asked to implement a bag collection using a linked list and, in order to focus on the linked list implementation details, we will implement the collection to store only one type of object of your choice (i.e., not generic). You can use the object you created for program #2 IMPORTANT: You may not use the LinkedList class from the java library. Instead, you must implement your own linked list...
MasterMind in Java
Activity
MasterMind project
Create a new Java Application project named MasterMind
allowing Netbeans IDE to create the main class called
MasterMind.java
MasterMind class
Method main() should:
Call static method System.out.println() and result in
displaying “Welcome to MasterMind!”
Call static method JOptionPane.showMessageDialog(arg1, arg2)
and result in displaying a message dialog displaying “Let’s Play
MasterMind!”
Instantiate an instance of class Game()
constants
Create package
Constants class
Create class Constants
Create constants by declaring them as “public static final”:
public...
Course, Schedule, and ScheduleTester (100%) Write a JAVA program that meets the following requirements: Course Class Create a class called Course. It will not have a main method; it is a business class. Put in your documentation comments at the top. Be sure to include your name. Course must have the following instance variables named as shown in the table: Variable name Description crn A unique number given each semester to a section (stands for Course Registration Number) subject A...
1. Create a UML diagram to help design the class described in Q2 below. Do this exercise before you attempt to code the solution. Think about what instance variables will be required to describe a Person class object; should they be private or public? Determine what class methods are required; should they be private or public?2. Write Java code for a Person class. A Person has a name of type String and an age of type integer.Supply two constructors: one will be...
> 3 inter-dependent invariants are missing
Overloaded Constructor is also missing.
Huyen Nguyen Sun, Nov 28, 2021 6:02 PM