Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 17th, 2012  |  syntax: None  |  size: 3.02 KB  |  hits: 22  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import java.util.Vector;
  2.  
  3. import javax.swing.JOptionPane;
  4.  
  5.  
  6. public class Bank {
  7.         private static float bankBalance;
  8.         private static Client[]bankClients;
  9.         private static Logger logService;
  10.         private static String accountUpdater;
  11.        
  12.         private static Bank bankInstance=null;
  13.         private Bank() {
  14.                 this.bankBalance=bankBalance;
  15.                 this.bankClients=bankClients;
  16.             Client[] BankClients = new Client[100];
  17.             bankBalance=0;
  18.                 this.logService=logService;
  19.         }
  20.         public static Bank getInstance(){
  21.                 if(bankInstance==null){
  22.                         bankInstance = new Bank();
  23.                 }
  24.                 return bankInstance;
  25.         }
  26.         public static float getBalance(){
  27.                 float totalClientBalance=0;
  28.                 for(int index=0; index<100; index++){
  29.                         totalClientBalance +=  bankClients[index].getClientBalance() + bankClients[index].getFortune();
  30.                 }
  31.                 return bankBalance;
  32.         }
  33.         public void setBalance(float amount){
  34.                 bankBalance += amount;
  35.         }
  36.        
  37.         public static void addClient(){
  38.                 Client newClient;
  39.                 String input= JOptionPane.showInputDialog("What kind of client would you like to add R=regular, G=gold, P=platinum ?");
  40.                 while (!input.equalsIgnoreCase("R") && !input.equalsIgnoreCase("G") && !input.equalsIgnoreCase("P")){
  41.                         JOptionPane.showInputDialog(null, "Error.Select R, G or P");
  42.                         input = JOptionPane.showInputDialog("What kind of client would you like to add R=regular, G=gold, P=platinum ?");
  43.                 }
  44.                 int id=0;
  45.                 while ((id<100)&&(bankClients[id]!= null)){
  46.                         id++;
  47.                 }
  48.                 if(input.equalsIgnoreCase("R")){
  49.                         String inputName = JOptionPane.showInputDialog("Enter new client name");
  50.                         String inputBalance = JOptionPane.showInputDialog("Enter amount of money to open account");
  51.                         Float f = new Float(inputBalance);
  52.                     newClient = new RegularClient (id, inputName, f);
  53.                 }
  54.                 /*if (ID<100)
  55.                 {
  56.                         bankClients[ID]=newClient ;      
  57.                         Log log = new Log (0, newClient.getClientId(), "client was added" );
  58.                         Logger logger = new Logger();
  59.                         logger.log(log);
  60.                 }*/
  61.         }
  62.        
  63.         public void removeClient(int ClientId){
  64.                 int index=0;
  65.                 while (bankClients[index].getClientId()!= ClientId)     {
  66.                         index++;
  67.                 }
  68.                 // ערך שאותו הבנק מאבד עם מחיקת הלקוח- המורכב מעו"ש וערך סך כל החשבונות
  69.                         float lostBalance = bankClients[index].getClientBalance()+bankClients[index].getFortune();
  70.                         bankBalance -= lostBalance;
  71.                         bankClients[index] = null;
  72.                         Log log = new Log(0, bankClients[index].getClientId(), "Client removed");
  73.                         Logger.log(log);
  74.         }
  75.        
  76.         public void getClients()        {
  77.                 printSpace();
  78.                 System.out.println("Id\t Client Type\t Name\t Interest\t Comission");
  79.                 System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
  80.                 for(int index=0; index<bankClients.length; index++){
  81.                         System.out.println("Id(" + (index+1)+ ")\t" + bankClients[index]);
  82.                 }
  83.         }
  84.         public void printSpace(){
  85.                 for(int index=0; index<5; index++){
  86.                         System.out.println();
  87.                 }
  88.         }
  89.         public void printLogs(){
  90.                 System.out.println();
  91.         }
  92.        
  93.         public void startAccountUpdater(){
  94.                
  95.         }
  96.         public void printClientList(){
  97.                 System.out.println();
  98.         }
  99. }