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

Im creating a java application for a project, and I was wondering if anyone coul

ID: 653219 • Letter: I

Question

Im creating a java application for a project, and I was wondering if anyone could tell me if I coded this class right. The comments are all the things that im supposed to have completed when attemping this class.

/**
* The Device class for the device object.
*
* The Device class creates a device object with a
* device number, owner name, and a phone number.
*
* @author Your Name
* @version 0.0
*/
public class Device
{
private int deviceNum;
private String ownerName;
private String phoneNum;

/**
* The Device Constructor.
*
* It sets the fields from the parameters
*
* @param deviceNum The Device's number.
* @param ownerName The Owner's name.
* @param phoneNum The Owner's phone number.
*/
public Device(int deviceNum, String ownerName, String phoneNum)
{
this.deviceNum = deviceNum;
this.ownerName = ownerName;
this.phoneNum = phoneNum;
}

/**
* Mutator for DeviceNum.
*
* Allows you to set deviceNum from another class.
* Should ensure that it is not 0 or below.
* If it is below 0, it should throw an exception.
*
* @param deviceNum The Device Number.
* @throws java.lang.Exception
*/
public void setDeviceNum(int deviceNum) throws Exception
{
this.deviceNum = deviceNum;
}

/**
* Mutator for ownerName.
*
* Allows you to set ownerName from another class.
*
* It ensures that the ownerName is not null before it puts it in,
* Throws an exception if it is null.
*
* @param ownerName The Owner's Name.
* @throws java.lang.Exception
*
*/
public void setOwnerName(String ownerName) throws Exception
{
this.ownerName = ownerName;
}

  
/**
* Mutator for PhoneNum.
*
* Allows you to set phoneNum from another class.
*
* It ensures that the phoneNum is not null before it puts it in,
* Throws an exception if it is null.
*
* @param phoneNum the owner's phone number.
* @throws java.lang.Exception
*/
public void setPhoneNum(String phoneNum) throws Exception
{
this.phoneNum = phoneNum;
}


/**
* Accessor for device number.
*
* Returns deviceNum.
*
* @return returns device number.
*/
public int getDeviceNum()
{
return 0;
}

/**
* Accessor for owners name
*
* returns ownerName.
*
* @return returns owner's name.
*/
public String getOwnerName()
{
return ownerName;
}

/**
* Accessor for phone number.
*
* returns phoneNum
*
* @return returns phone number.
*/
public String getPhoneNum()
{
return phoneNum;
}

/**
* To String method.
*
* This is what you will do to display each device.
* They should display as such.
* deviceNum ownerName phoneNum
* Do not forget the new line character at the end.
*
* @return returns the string.
*/
@Override
public String toString()
{
return "deviceNum: " + deviceNum + " " +
"ownerName: " + ownerName + " " +
"phoneNum: " + phoneNum + " ";
}

/**
* equals method.
*
* use this to see if two devices are equal.
* Compare the fields of each, if one is different, return false
* otherwise, return true.
*
* @param dev
* @return returns logic based on it's equality.
*/
public boolean equals(Device dev)
{
if (dev instanceof Device)
{
Device device2 = (Device) dev;
if
(
deviceNum==(device2.getDeviceNum()) &&
ownerName.equals(device2.getOwnerName()) &&
phoneNum.equals(device2.getPhoneNum())
)
return true;
}
return false;

}
}

Explanation / Answer

It compiled and return with no errors.

Programming logic looks like good but not sure becuse, there is no full details regarding your project.