Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions student-submission/BESE2018/SarojAryal-19180079/MyClient.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
Original file line number Diff line number Diff line change
@@ -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) ;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Display all the output in client console.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay sir.

Copy link
Author

@joerush18 joerush18 Jan 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public double calculateTax(double amount) { return amount * taxRate / 100; }

sir why can't i do this on my MyInterface.java ?

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;
}
}
17 changes: 17 additions & 0 deletions student-submission/BESE2018/SarojAryal-19180079/MyInterface.java
Original file line number Diff line number Diff line change
@@ -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;
}
21 changes: 21 additions & 0 deletions student-submission/BESE2018/SarojAryal-19180079/MyServer.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
1 change: 1 addition & 0 deletions student-submission/BESE2018/SarojAryal-19180079/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is for the test.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions student-submission/BESE2018/bibek/MyInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}