The CompInfo.java file is used to provide the computer information, such as echo time and current system date and time of a specific computer.
Listing 7-3 shows the contents of the CompInfo.java file:
/* Class CompInfo - This class provides the computer information of specific computer. Fields: address - Contains the IP address of the computer. info - Contains the computer information's, such as echo time or date/time. Methods: getAddress() - This method returns the IP address of the computer. getCompInfo() - This method returns the computer information. */ public class CompInfo { /* Declares and initializes the objects of String class. */ private String address = null; private String info = null; /* Defines the default constructor. */ public CompInfo(String address, String info) { this.address = address; this.info = info; } /* getAddress() - This method is used to retrieve the IP address of a specified computer. Parameter: NA Return Value: String */ public String getAddress() { return this.address; } /* getCompInfo() - This method is used to retrieve the computer information of a specified computer. Parameter: NA Return Value: String */ public String getCompInfo() { return this.info; } }
Download this Listing .
In the above code, the constructor of the CompInfo class takes the host IP and computer information as input parameters. The methods defined in the above code are:
getAddress() : Returns the IP address of the selected computer.
getCompInfo() : Returns computer information, such as echo time and current system date and time of the selected network computer.