есть 2 файла.
String IP должна меняться. но этого не происходит, почему?
КОД
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Client
{
private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
private static String IP;
public Client() throws IOException
{
IP = "192.168.1.5";
index(IP);
}
public static void setIP(String IP)
{
Client.IP = IP;
}
private void index(String IP) throws IOException
{
System.out.print("What do you want to do? --> ");
String command = reader.readLine();
if (command.equals("Change my IP adress"))
{
System.out.println("Your IP before changing: "+getIP());
new Soft(IP);
System.out.println("Your IP after changing: "+getIP());
}
}
public static String getIP()
{
return IP;
}
public static void main(String[] args) throws IOException
{
new Client();
}
}
ВТОРОЙimport java.util.Random;
public class Soft
{
private String IP;
Random rand = new Random();
public Soft(String IP)
{
this.IP = IP;
changeMyIPAdress(IP);
}
private void changeMyIPAdress(String IP)
{
this.IP = rand.nextInt(200)+"."+rand.nextInt(200)+"."+rand.nextInt(200)+rand.nextInt(200);
Client.setIP(IP);
}
}