java : object oriented , how it works and how to set the getter and setter ?
from the Question above , I dont have a good Idea about OOP
please , I have a peace of code the does not work
public class Computer {
protected String hostName;
private int IPAddress;
Computer(String h, int i){
this.hostName = h;
this.IPAddress = i;
}
public int getIPAddress(){
return IPAddress;
}
public void setIPAddress(int i){
IPAddress = i;
}
public String searchIP(string c){
this.computerName = c;
if (this.computerName=("localhost"))
return "the IP address is 127.0.0.1";
}
}
|