Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Below are the instructions for the main class of a project I creating. I have do

ID: 655639 • Letter: B

Question

Below are the instructions for the main class of a project I creating. I have done as much as I can since im new to java alot of this stuff is over my head. The code below also contains comments that tell what should go where as well any help would be greatly appreciated.

******************************

The SupportCenter Class

This class is what will hold your main method. It starts with just 2 methods and 1 field in it. The field is a DeviceList named dl and the methods are a no-args constructor and your main method. The no-args constructor should just make a DeviceList by calling its no-args constructor. The main(String[] args) method will run the entire simulation, instantiating a Scanner object and a SupportCenter object, then calls helper methods to run the rest of the simulation. This method can only be at most 10 lines, so use your knowledge of how to write methods to break it down into meaningful chunks.

Here is what your menu should look like

1. Add a Device

2. Remove a device by Device Number

3. Remove a device by Name or Phone Number

4. Lookup a device by Device Number

5. Lookup a device by Name or Phone Numbe

6. Print all devices

0.Quit

Use a decision making structure to determine what to do after the input of a number into the system from the user.

Option one should prompt you for the information to make a device, then add that device to the DeviceList.

Option 2 and 3 should remove a device from the DeviceList based on the input from the user.

4 and 5 should print out the information from a device that matches whatever the user input.

6 should print out the information of all of the devices in the Device List

0 should end the program.

**********************************************************

package supportcenter;


import java.util.Scanner;


/**
* This class runs the system.
*
* It holds the main for the entire program.
* Make a menu that can be used to call the methods
* in this class other than the main, input, constructor, and makeMenu.
*
* @author Your Name
* @version 0.0
*/
public class SupportCenter {

private final DeviceList dl;
  

/**
* No-arg constructor for SupportCenter class.
* Must initialize a dl as a new Device List
*
*/
public SupportCenter()
{
  
dl = new DeviceList();//no arg constructor
  
}

/**
* Main method for the program.
* Needs to create a create a SupportCenter object, a scanner, and call helper methods
* to print the menu and take in input.
*
* @param args - command line arguments.
*/
public static void main(String[] args){
  
SupportCenter dl = new DeviceList(); //Object
  
Scanner input = new Scanner(System.in); //Scanner
  
}

/**
* This method handles the input from the user.
*
* @param sc - scanner passed from main.
*/
public void input(Scanner sc)
{

String OwnerName;
String phoneNum;
int deviceNum;

// Allows a person to enter his/her name   
Scanner Scanner(System.in);
System.out.println("Enter Owner Name:" );
OwnerName = one.next();
System.out.println("Name accepted " + OwnerName);
  
// Allows a person to enter his/her name   
Scanner two = new Scanner(System.in);
System.out.println("Enter Phone Number:" );
phoneNum = two.next();
System.out.println("Phone Number accepted " + phoneNum);
  
// Allows a person to enter his/her gender
Scanner three = new Scanner(System.in);
System.out.println("Enter Device Number:" );
deviceNum = three.nextInt();
System.out.println("Device Number accepted " + deviceNum);
  

}

/**
* This method prints the menu.
* It is called after each input is complete.
*
*/
public void makeMenu()
{

}

/**
* This method handles making and adding a new device to the DeviceList.
*
* @param deviceNum
* @param ownerName
* @param phoneNum
*/
public void add(int deviceNum, String ownerName, String phoneNum)
{
  
}

/**
* This removes a device by device number.
*
* @param deviceNum
*/
public void remove(int deviceNum)
{

}

/**
* Removes device by either phoneNum or ownerName.
*
* @param info
*/
public void remove(String info)
{

}

/**
* looks up and prints a device by its number.
*
* @param deviceNum
*/
public void lookup(int deviceNum)
{
  
}

/**
* looks up and prints a device by phoneNum or ownerName.
*
* @param info
*/
public void lookup(String info)
{

}

/**
* Prints all of the devices.
*
*/
public void printAll()
{

}
}

*******************************************************

package supportcenter;

/**
* This class will be the data structure used in this program.
*
* It uses an array of Devices as the storage, and uses numDevices
* to track how many Devices have been entered into the array.
* This allows only the devices to be iterated through rather than the
* entire array.
*
* @author Your Name
* @version 0.0
*/

public class DeviceList extends SupportCenter
{

private Device[] array;
private int numDevices;

/**
* No-arg constructor.
* Set fields to defaults.
* array should be of size 50.
*
*/
//Default constructor that sets the numDevices and intiailiz
//the array of default size
public DeviceList()
{
numDevices = 50;
array = new Device[numDevices];
}
/**
* args Constructor.
* set fields equal to parameters.
*
* @param devList
* @param numDevices - number of devices in array.
*/
//Parameterized constructor that sets the numDevices and intiailiz
//the array of given size
public DeviceList(Device[] devList, int numDevices)
{
this.numDevices = numDevices;
array = new Device[numDevices];

for (int index = 0; index < numDevices; index++)   
array[index]=devList[index];
}

/**
* Accessor for array. Needed in SupportCenter.
*
* @return Device[]
*/
public Device[] getArray()
{
return array;
}

/**
* Add a new device from a device that is already made.
* Check to see if the new device already exists in the array,
* if not, add it to the end and increment numDevices.
*
* @param dev
*/
public void add(Device dev)
{
if(lookup(dev.getDeviceNum())==null &&
lookup(dev.getOwnerName())==null)
{
Device[] deviceList=new Device[array.length];

deviceList=array;
numDevices=numDevices+1;
array=new Device[numDevices];

for (int index = 0; index < deviceList.length; index++)
{
array[index]=deviceList[index];
}

array[numDevices-1]=dev;

}
}

/**
* Removes a device that is equal to dev.
* Uses its own lookup to check if dev is equal to anything in the array.
* if so, it removes it in the same way as the other removes
* Check to see if there are any devices in the list first.
*
* @param dev
*/
public void remove(Device dev)
{
boolean found=false;

for (int index = 0; index < numDevices && !found; index++)
{
if(dev.getDeviceNum()==array[index].getDeviceNum() &&
dev.getOwnerName().equalsIgnoreCase(array[index].getOwnerName()) &&
dev.getPhoneNum().equalsIgnoreCase(array[index].getPhoneNum()))
{
found=true;
array[index]=null;
}
}

if(!found)
System.out.println("Device not found");

}

/**
* Removes a device with the same device deviceNum
* Looks up the device based off deviceNum provided, if not found it prints an error
* if it is not the last device in the list, it is replaced by the last device in the list
* if it is the last device, it makes that index null in the array
* it decrements numDevices if the device is found.
*
* @param deviceNum
*/
@Override
public void remove(int deviceNum)
{
boolean found=false;

for (int index = 0; index < numDevices && !found; index++)
{
if(array[index].getDeviceNum()==deviceNum)
{
found=true;
array[index]=null;
}
}

if(!found)
System.out.println("Device not found");

}

/**
* Removes a device with the same name or phone.
* Looks up the device based off of info provided, if not found it prints an error
* if it is not the last device in the list, it is replaced by the last device in the list
* if it is the last device, it makes that index null in the array
* it decrements numDevices if the device is found.
*
* @param info - name or phone number.
*/
@Override
public void remove(String info)
{
boolean found=false;

for (int index = 0; index < numDevices && !found; index++)
{
if(array[index].getOwnerName().equalsIgnoreCase(info)||
array[index].getPhoneNum().equals(info))
{
found=true;
array[index]=null;
}
}

if(!found)
System.out.println("Device not found");

}

/**
* Returns a device with a given deviceNum.
* This should search the array and return the index of the last device with
* the given deviceNum.
*
* @param deviceNum
* @return Device
*/
public Device lookup(int deviceNum)
{
if(deviceNum>0 && deviceNum<numDevices)
return array[deviceNum];
else
return null;
}

/**
* Returns a device with a given phone number or name.
* This should search the array and return the index of the last device with
* the given ownerName or phoneNum.
*
* @param info
* @return Device
*/
public Device lookup(String info)
{
for (int index = 0; index < numDevices; index++)
{
if(array[index]!=null)
if(array[index].getOwnerName().equalsIgnoreCase(info)|| array[index].getPhoneNum().equals(info))
return array[index];
}

return null;

}

/**
* toString for DeviceList.
* This should display the return a string made up of the strings from each Device in the array.
*
* @return String
*/
@Override
public String toString()
{
String deviceList="";
int index;
for (index = 0; index < numDevices; index++)
{
if(array[index]==null)
deviceList+="Null ";
else
deviceList+=array[index].toString()+" ";

}

return deviceList;
}
}

Explanation / Answer

You will greatly appreciated on the creation of classes . You have created differnt class for different function and it will be easy to use those as the user know here to which class a user can acces.The apprication you will get on the structure of your program as the structure looks simple and can clear about the program . The program looks simple and easily provide the output easily

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote