Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.rmi.*;
- public interface Stationery extends Remote
- {
- public boolean available(String prod)throws RemoteException;
- int bill(String prod,int qty)throws RemoteException;
- String goodbye()throws RemoteException;
- }
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- import java.rmi.*;
- import java.rmi.server.*;
- public class StationeryImplementation extends UnicastRemoteObject implements Stationery
- {
- String products[]={"Pen","Apsara Pencil","Natraj Pencil"};
- int quanty[]={10,10,10};
- int price[]={100,5,4};
- StationeryImplementation()throws RemoteException
- {
- }
- public boolean available(String prod)throws RemoteException
- {
- for(int i=0;i<products.length;i++)
- if(prod.equalsIgnoreCase(products[i]))
- return true;
- return false;
- }
- public int bill(String prod,int qty)throws RemoteException
- {
- int amount=0;
- for(int i=0;i<products.length;i++)
- if(prod.equalsIgnoreCase(products[i]))
- if(qty<=quanty[i])
- {
- amount+=price[i]*qty;
- }
- return amount;
- }
- public String goodbye()throws RemoteException
- {
- return "Thank You";
- }
- }////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- import java.rmi.*;
- import java.rmi.server.*;
- public class StationeryServer
- {
- public static void main(String args[])throws Exception
- {
- StationeryImplementation si=new StationeryImplementation();
- Naming.rebind("Stats",si);
- }
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- import java.rmi.*;
- import java.io.*;
- public class StationeryClient
- {
- public static void main(String args[])throws Exception
- {
- Stationery st=(Stationery)Naming.lookup("rmi://localhost/Stats");
- System.out.println(st.available("Pen"));
- System.out.println(st.bill("Pen",5));
- System.out.println(st.goodbye());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement