-
Notifications
You must be signed in to change notification settings - Fork 30
Add Saroj Aryal's 19180079 lab #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
joerush18
wants to merge
2
commits into
pusoe:master
Choose a base branch
from
joerush18:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
student-submission/BESE2018/SarojAryal-19180079/MyClient.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
student-submission/BESE2018/SarojAryal-19180079/MyImplementation.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) ; | ||
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
17
student-submission/BESE2018/SarojAryal-19180079/MyInterface.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
21
student-submission/BESE2018/SarojAryal-19180079/MyServer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This is for the test. |
Binary file added
BIN
+59.9 KB
student-submission/BESE2018/SarojAryal-19180079/Screenshots/Myoutput.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay sir.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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 ?