iKonto.java

Java RMI

import java.io.Serializable;
import java.rmi.Remote;
import java.rmi.RemoteException;

public interface iKonto 
	extends Remote,Serializable{
	
	public int getId() 
		throws RemoteException;
	public String getHaslo() 
		throws RemoteException;
	
	public double getSaldo() 
		throws RemoteException ;

	public void setImie(String imie) 
		throws RemoteException;
	public String getImie() 
		throws RemoteException ;

	public void setNazwisko(String nazwisko) 
		throws RemoteException;
	public String getNazwisko() 
		throws RemoteException ;
	
	public double zdejmijZRachunku (double kwota) 
		throws RemoteException ;
	public double uznajNaRachunek (double kwota) 
		throws RemoteException ;
}

Konto.java

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Serializable;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

public class Konto extends UnicastRemoteObject implements iKonto,Serializable{
	private static final long serialVersionUID = 1L;
	
	private String imie = "";
	private String nazwisko = "";
	private String haslo = "";
	private int id ;
	private double saldo;
	
	public Konto(String ti, String tn, int tid) throws RemoteException{
		saldo = 0;
		imie = ti;
		nazwisko = tn;
		haslo = Haslo.getUniqueID();
		id = tid;
	}

	private static void log(String s){
 	   try {
 	        BufferedWriter out = new BufferedWriter(new FileWriter("Bank.log.txt", true));
 	        out.write(s+"\n");
 	        out.close();
 	    } catch (IOException e) {
 	    }
	}

	public double zdejmijZRachunku (double kwota) throws RemoteException {
		if (kwota <= saldo){
			saldo -= kwota;
			log("zdejmij z rach "+ id + " " + kwota);
		}
		return saldo;
	}

	public double uznajNaRachunek (double kwota) throws RemoteException {
		log("uznaj rachunek "+ id + " " + kwota);
		saldo += kwota;
		return saldo;
	}
	public double getSaldo()  throws RemoteException {
		return saldo;
	}
	public int getId() throws RemoteException{
		return id;
	}
	public String getHaslo() throws RemoteException{
		return haslo;
	}
	public void setHaslo(String haslo) throws RemoteException{
		this.haslo = haslo;
	}
	public String getImie() throws RemoteException {
		return imie;
	}
	public void setImie(String imie) throws RemoteException{
		this.imie = imie;
	}
	public String getNazwisko() throws RemoteException {
		return nazwisko;
	}
	public void setNazwisko(String nazwisko) throws RemoteException{
		this.nazwisko = nazwisko;
	}
}

2012.11.22 22:29:15.