public class Machine { private String name; private int id; private Part part; } public Machine (String xname, int…

public class Machine { private String name; private int id; private Part part; } public Machine (String xname, int…

Question:

Transcribed Image Text:

public class Machine
{
private String name;
private int id;
private Part part;
}
public Machine (String xname, int xid)
{
name = xname;
id = xid;
part == null;
}
) Assume the following Machine and Part classes:
public class Part
{
private String type;
private int num;
private Machine machine;
}
}
public Part (String xtype, int xnum)
{
type = xtype;
num = xnum;
machine= null;
Puce CN
Public
Write a Java method in the Machine class to create a new part object.

Expert Answer:

Answer rating: 100% (QA)

Certainly To create a new Part object in the Machine class you can add a method c
View the full answer