Question: Written in Java I need help with my errors so the code will run and I need this to be implemented into the code with
Written in Java I need help with my errors so the code will run
and I need this to be implemented into the code with comments throughtout
- Overload method PrintDate(),,,,When Location is null or empty, call the parents method PrintDate(), or else, print Location information and is not allowed to display printDate for clients"
- Create class of testClient
- build main method to test the classes you defined before,,,,,build an object of class PrintClient named pc, call the method PrintDate in PrintClient, set the value of field Location to Classroom",recall the method PrintDate
`import java.util.Date;
class Main
{
public static void main(String[] args)
{
// creating new PrintClient object pc
PrintClient pc = new PrintClient();
// calling method printDate in PrintClient
pc.printDate();
// setting value of field location to "Classroom"
pc.setLocation("Classroom");
// recalling method PrintDate
pc.printDate();
}
}
class Client
{
// private fields
private int ID;
private int port;
private String name;
// constructor first one
public Client()
{
}
// constructor second one
public Client(int id)
{
ID = id;
}
// constructor third one
public Client(int id, int p)
{
ID = id;
this.port = p;
}
// constructor fourth one
public Client(int id, int p, String n)
{
ID = id;
this.port = p;
this.name = n;
}
// getters and setters
public int getID()
{
return ID;
}
public void setID(int iD)
{
ID = iD;
}
public int getPort()
{
return port;
}
public void setPort(int port)
{
this.port = port;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public void printDate()
{
System.out.println("Print date of Client class");
}
}
// childrens class of contents
class PrintClient extends Client
{
// new field location
private String location;
// gets and sets
public String getLocation()
{
return location;
}
public void setLocation(String location)
{
this.location = location;
}
// printDate method
public void printDate()
{
Date d = new Date();
System.out.println(d.toString());
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
