Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.rmi.RemoteException;
- import java.rmi.server.UnicastRemoteObject;
- import java.util.Scanner;
- public class Implement extends UnicastRemoteObject implements Chatting
- {
- public String[] r;
- public String o = "", o1 = "", o2 = "";
- public Implement() throws RemoteException
- {
- super();
- }
- @Override
- public String getMessage() throws RemoteException
- {
- Scanner sc = new Scanner(System.in);
- System.out.print("My Message: ");
- //String message = sc.next();
- String message = "";
- if (o.equals("+"))
- {
- message = Double.toString(Double.parseDouble(o1) + Double.parseDouble(o2));
- }
- else if (o.equals("-"))
- {
- message = Double.toString(Double.parseDouble(o1) - Double.parseDouble(o2));
- }
- else if (o.equals("*"))
- {
- message = Double.toString(Double.parseDouble(o1) * Double.parseDouble(o2));
- }
- else if (o.equals("/"))
- {
- try
- {
- message = Double.toString(Double.parseDouble(o1) / Double.parseDouble(o2));
- }
- catch (Exception e)
- {
- message = e.getMessage();
- }
- }
- return message;
- }
- @Override
- public void sendMessage(String s) throws RemoteException
- {
- System.out.println("Client's Message: " + s);
- r = s.split(":");
- o1 = r[0];
- o2 = r[1];
- o = r[2];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement