diff --git a/student-submission/BESE2018/SarojAryal-19180079/MyClient.java b/student-submission/BESE2018/SarojAryal-19180079/MyClient.java new file mode 100644 index 0000000..1a739af --- /dev/null +++ b/student-submission/BESE2018/SarojAryal-19180079/MyClient.java @@ -0,0 +1,30 @@ +import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; +import java.util.*; + + +public class MyClient { + private MyClient(){} + public static void main(String[] args) { + try{ + Registry registry = LocateRegistry.getRegistry("localhost"); + MyInterface stub = (MyInterface) registry.lookup("MyInterface"); + try (Scanner scanner = new Scanner(System.in)) { + System.out.println("Enter the amount : "); + double amount = scanner.nextDouble(); + System.out.println("Enter the tax rate: "); + double taxRate = scanner.nextDouble(); + stub.setTaxRate(taxRate); + System.out.println("The tax amount is: " + stub.calculateTax(amount)); + stub.printMsg(); + System.out.println("Area of circle: " + stub.calculateAreaOfCircle(5.0) + " sq. units"); + System.out.print("Volume of rectangle: " + stub.calculateVolumeOfRectangle(15.0, 19.5, 5.14) + " cubic units"); + } + + } + catch(Exception e) { + System.err.println("Client exception: " + e.toString()); + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/student-submission/BESE2018/SarojAryal-19180079/MyImplementation.java b/student-submission/BESE2018/SarojAryal-19180079/MyImplementation.java new file mode 100644 index 0000000..0889e21 --- /dev/null +++ b/student-submission/BESE2018/SarojAryal-19180079/MyImplementation.java @@ -0,0 +1,31 @@ +public class MyImplementation implements MyInterface +{ + + private double taxRate; + + public void printMsg() + { + System.out.println("I am implemented class."); + } + + public double calculateAreaOfCircle(double radius){ + final double PI = 3.1415; + System.out.println("The area of circle: " + PI * radius * radius ); + return PI * radius * radius; + } + + public void setTaxRate(double taxRate){ + this.taxRate = taxRate; + + } + + public double calculateTax(double amount) { + System.out.println("The tax amount is: " + amount * taxRate / 100) ; + return amount * taxRate / 100; + } + + public double calculateVolumeOfRectangle(double length, double breadth, double height) { + System.out.println("The volume of rectangle is: " + length * breadth * height); + return length * breadth * height; + } +} diff --git a/student-submission/BESE2018/SarojAryal-19180079/MyInterface.java b/student-submission/BESE2018/SarojAryal-19180079/MyInterface.java new file mode 100644 index 0000000..db6cd0d --- /dev/null +++ b/student-submission/BESE2018/SarojAryal-19180079/MyInterface.java @@ -0,0 +1,17 @@ +import java.rmi.Remote; +import java.rmi.RemoteException; + +public interface MyInterface extends Remote +{ + public void printMsg() throws RemoteException; + + + public double calculateAreaOfCircle(double radius) throws RemoteException; + + public double calculateTax(double amount) throws RemoteException; + + public void setTaxRate(double taxRate) throws RemoteException; + + + public double calculateVolumeOfRectangle(double length, double breadth, double height) throws RemoteException; +} diff --git a/student-submission/BESE2018/SarojAryal-19180079/MyServer.java b/student-submission/BESE2018/SarojAryal-19180079/MyServer.java new file mode 100644 index 0000000..59807d9 --- /dev/null +++ b/student-submission/BESE2018/SarojAryal-19180079/MyServer.java @@ -0,0 +1,21 @@ +import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; +import java.rmi.server.UnicastRemoteObject; + +public class MyServer extends MyImplementation +{ + public MyServer(){} + public static void main(String args[]) + { + try { + MyImplementation imp = new MyImplementation(); + MyInterface stub = (MyInterface) UnicastRemoteObject.exportObject(imp, 8080); + Registry registry = LocateRegistry.getRegistry(); + registry.rebind("MyInterface", stub); + System.err.println("Server is ready"); + } catch(Exception e) { + System.err.println("Server exception: " + e.toString()); + e.printStackTrace(); + } + } +} diff --git a/student-submission/BESE2018/SarojAryal-19180079/README.md b/student-submission/BESE2018/SarojAryal-19180079/README.md new file mode 100644 index 0000000..7a84189 --- /dev/null +++ b/student-submission/BESE2018/SarojAryal-19180079/README.md @@ -0,0 +1 @@ +This is for the test. diff --git a/student-submission/BESE2018/SarojAryal-19180079/Screenshots/Myoutput.png b/student-submission/BESE2018/SarojAryal-19180079/Screenshots/Myoutput.png new file mode 100644 index 0000000..867c292 Binary files /dev/null and b/student-submission/BESE2018/SarojAryal-19180079/Screenshots/Myoutput.png differ diff --git a/student-submission/BESE2018/bibek/MyInterface.java b/student-submission/BESE2018/bibek/MyInterface.java index acbfc26..d3ab6fa 100644 --- a/student-submission/BESE2018/bibek/MyInterface.java +++ b/student-submission/BESE2018/bibek/MyInterface.java @@ -5,15 +5,15 @@ public interface MyInterface extends Remote { public void printMsg() throws RemoteException; // method to calculate the area of circle - public void calculateAreaOfCircle(double radius) throws RemoteException; + public double calculateAreaOfCircle(double radius) throws RemoteException; // calculate the tax amount - public void calculateTax(double amount) throws RemoteException; + public double calculateTax(double amount) throws RemoteException; // set the tax rate public void setTaxRate(double taxRate) throws RemoteException; // calculate the volume of rectangle - public void calculateVolumeOfRectangle(double length, double breadth, double height) throws RemoteException; + public double calculateVolumeOfRectangle(double length, double breadth, double height) throws RemoteException; }