Asagidaki program bizden 3 Adet sinifi programi olan bir banka yazmamizi istiyor
In a simplified banking system each customer holder of a
one account. A bank account is characterized by a number of
account and a balance. The account number uniquely identifies an account.
In accordance with the policies of the bank, the balance of a bank account
can not be negative. A customer is characterized by a name, a number of
client, a PIN and the bank account mentioned in the holder. The number of customer
uniquely identifies the customer.
operations that can be made up of a bank account (Account
class) are (at least) the following: *
public Account () default constructor that assigns to this account
a unique number and sets the balance to zero.
Public Account * (double saldoIniziale) manufacturer that assigns a unique number that
account and set the balance to an initial value specified by
saldoIniziale.
* public void deposit (double that) that increments the balance of the amount of
bank account specified by how much.
* public boolean withdraw (double as) that, if possible, taken from
this bank account as specified by a quantity;
the method returns true if the levy was made, false otherwise
. Public double ritornaSaldo
* () which returns the current value of the balance of this
bank account. * Public boolean
transfer (other income, double what) that transfers
if possible, an amount equal to that from this account to the account specified by another
; returns true if the transfer was made
, false otherwise.
The operations that can be made about a customer (customer class)
are (at least) the following: *
public Customer (String name, int pin, Bill contoCliente) that assigns
to this client a customer number and unique sets the name, PIN and the account referred
holder.
* public boolean test (int numCliente, int pin) that checks whether
numCliente and pin are respectively the number of client and that client
PIN. Public int ritornaNumCliente
* () which returns the customer number
of this customer.
operations that can be made on the bank are (at least)
the following: *
public Bank () that sets the maximum number of customers of this bank
a default initial value equal to DEFAULT_MAXNUM_CLIENTI. *
public Bank (int numClienti) that sets the maximum number of customers of this bank
to an initial value specified by numClienti;
if this parameter specifies a value less than 1, the constructor sets
the number of customers to default DEFAULT_MAXNUM_CLIENTI .
* public boolean add (Customer customer) that adds to this bank a new customer
specified by customer returns true if the customer is actually
added, false if the bank does not '
able to handle other customers.
* public boolean delete (int numCliente) that eliminates this
the bank customer who has the specified number, returns true if the customer is effectively eliminated
false otherwise. *
public Customer find (int number) that returns the customer that the specified number
, returns null if the customer is not present. * Public boolean
transfer (numClienteSrg int, int numClienteDst, double as)
transferring the amount between what the bank accounts of two customers
of this bank, and the two clients are specified through their
customer number, the amount is transferred from the customer's account to the customer's account
numClienteSrg numClienteDst.
Provide all of a text interface that lets you perform certain transactions on a bank
. For example:
a) add client
b) delete customer
c) Customer is
d) tasferisci sum
s) to print data bank
Enter name: Enter pin
Pippo
:
1234
Enter beginning balance:
100
a) add client
b) delete customer
c) Customer is
d) tasferisci
and sum) print data bank and
Name = Goofy Pin Num = 0 = 1234 count = \u0026lt;0, 100.0>
Do so that classes Account, Customer and Bank belong
to a package (eg the bank package).
Program Kismi
package bank;
/ ** * A bank account
characterized by an account number and a *
balance. The account number uniquely identifies a bank account within
*. In accordance with the policies of the bank, the balance of a bank account
* can be negative.
* @ author Alessio Vecchio
* / public class Account
{/ ** * numaresi Hesap /
private int number;
/ ** * para hesabi /
private double balance;
/ * her muster icin tek bir kullanacagimiz icin Bir Numara making the static * / private static int numProgressivo
;
/ ** 0 to inaugurate the first account * / public
conto () {
this (0);}
/ ** Create the first deposit account that the money could not account for the low scratch control making the * /
public conto (double saldoIniziale) {
saldoIniziale = (saldoIniziale \u0026lt;0? 0: saldoIniziale);
saldo = saldoIniziale;
numero = numProgressivo + +;}
/ ** * Incrementa provincial saldo di questo
conto bancario della quantita 'specificata
* * /
public void deposit (double Quanto) {
/ /
if (Quanto \u0026lt;0) return
;
balance + = what;}
/ ** If possible, polishes the '
* specified.
* @ return true if the levy was made
*, false otherwise.
* /
public boolean withdraw (double as) {
/ * kullanici hesaptan cekmek isteyebilir para para ve baska hesaba aktarmak isteyebilir * /
if (what \u0026lt;0) return false
;
if (balance> = what) {
the balance -=;
return true;}
return false;}
/ ** Return the balance * / public double
ritornaSaldo () {return balance
;
} / ** *
transfer, se possibile, un pari a quantit Quanto also in questo altro specificato
* conto conto al. * @ Return true se il trasferimento
effettuato Staton, altrimenti false.
* / public boolean
trasferisci (altro conto, double Quanto) {
/ * a method that makes the transfer of money first before we check if you have the money, then asked to transfer to other account we ask how much, * /
if (prelievo (Quanto)) {
altro.deposito (Quanto);
return true;}
return false;}
/ ** * @ return
Rappresentazione stringa Formato del conto in \u0026lt;numero, saldo>
* /
public String toString () {
/ * muster numarasini para miktarini aktariyoruz * /
return "\u0026lt;" + number + "" + balance +">";
}}
package bank;
/ ** * A client
characterized by a name, account number, a PIN
* and that owner's bank account. The number of customer
* uniquely identifies the customer.
* @ author Alessio Vecchio
* / public class Customer
{/ ** Name of the client. * /
private String name;
/ ** Number of the customer. * / Private int
numCliente;
/ ** Pin reviews. * / Private int pin
;
/ ** client's behalf. * / Private
Account account;
/ **
sequential number used to assign unique numbers to customers. * / Private static int
numProgressivo;
/ ** Create a Customer object with the specified fields.
* The customer number and 'assigned automatically.
* /
public Customer (String name, int pin, Bill contoCliente) {
this.nome = name;
this.numCliente numProgressivo = + +;
this.pin = pin;
this.conto = contoCliente;
} / * * Create a customer account with an initial balance to 0 .* /
public Customer (String name, int pin) {
this (name, pin, new Account ());}
/ ** Check if numCliente and pin are respectively the number
* customer and this customer's PIN.
* / public boolean verify
(numCliente int, int pin) {return
numCliente this.numCliente & & pin == == this.pin;
} / ** * @ return The number
reviews.
* / public int
ritornaNumCliente () {return
numCliente;
} / ** * @ return
The name of the client.
* / public String
ritornaNomeCliente () {return name
;
} / ** * @ return
The customer's account.
* / public
ritornaConto Account () {return
account;
} / **
* @ return A representation of the client as a string.
* / public String toString
() {return
"Name =" + name + "Num =" + + numCliente "Pin =" + pin + "Count =" + account;
}}
package bank;
/
** * A bank manages bank accounts on behalf of its clients.
* @ author Alessio Vecchio
* / public class Bank {
/
** * Maximum number of customers that the bank can 'manage
* (unless otherwise noted).
* / private static final int
DEFAULT_MAXNUM_CLIENTI = 10;
/
** * Maximum number of customers that the bank can 'manage.
* / Private int
maxNumClienti;
/ ** *
Customers of the bank.
* /
Private Client [] clients;
/
** * Number of customers that the bank actually has.
* / private int
many;
/ ** Create a database that can handle the most 'DEFAULT_MAXNUM_CLIENTI * / public
Bank () {
this (DEFAULT_MAXNUM_CLIENTI)
} / ** Create a database handle specified the number of customers. * /
public Bank (int n) {
if (n \u0026lt;1) {n =
DEFAULT_MAXNUM_CLIENTI;}
this.maxNumClienti = n;
customer = new Customer [maxNumClienti]
quantity = 0;}
/ ** Adds the specified customer to the bank
* @ return true if the client is added, false
* if the bank can not 'handle other customers
* / public boolean add
(Customer customer) {
if (how = = maxNumClienti)
return false;
customers [those + +] = client;
return true;
}
/ ** Deletes the specified customer from the bank * /
public boolean delete (int numCliente) {
for (int i = 0; i \u0026lt;many; i + +) {
if (customers [i]. ritornaNumCliente () == numCliente) {
customers [i] = [customers - those] customers
[many] = null;
return true;
}
} return false;}
/ ** * Find
the client having the specified number.
* @ return null if that client is not 'present in the bank.
* /
public Customer find (int number) {
for (int i = 0; i \u0026lt;many; i + +)
if (customers [i]. RitornaNumCliente () == number)
return customers [i];
return null;
} / ** * Transfers the
amount between what the bank accounts of two
* Customers of this bank. The two clients are specified using *
of their customer number. * @ Param
numClienteSrg customer source. * @ Param
numClienteDst Customer recipient.
* @ Param what amount to transfer.
* / public boolean
transfer (numClienteSrg int, int numClienteDst, double as) {
Customer is SRG = (numClienteSrg)
Customer dst = find (numClienteDst)
if (dst == null s + = customers [i]. toString () + "\\ n";}
return s;}
} public class Menu {
/ / The bank that we manage. Private static
Bank bank = new Bank ();
/ ** Handles the input data needed to create a new user. * / Private static void
aggiungiCliente () {
Console.scriviStringa ("Enter name:");
Console.leggiStringa String name = ();
Console.scriviStringa ("Enter PIN:");
int pin = Console. leggiIntero ();
Console.scriviStringa ("Enter beginning balance:");
Console.leggiReale double balance = ();
Customer c = new Client (name, pin, new account (balance));
banca.aggiungi (c);}
/ ** Handles the menu head of research for a client. * / Private static
trovaCliente Customer () {
Console.scriviStringa ("Enter account number:");
Console.leggiIntero int num = ();
banca.trova return (num);}
/ ** Manages a menu to find a customer and prints the data. * / Private static void
trovaEStampaCliente () {Customer c =
trovaCliente ();
String s;
if (c == null) s =
"Customer not found";
else
c.toString s = ();
Console.scriviStringa (s);
} / ** Deletes a customer. * / Private static void
eliminaCliente () {
Console.scriviStringa ("Enter the customer number to delete:");
Console.leggiIntero int num = ();
if (banca.elimina (num)) {Console
. scriviStringa ("Client removed");
return;}
Console.scriviStringa ("Customer not found");}
/ ** Menu to transfer a sum from one user to another. * / Private static void
trasferisciSomma () {
Console.scriviStringa ("Source");
Customer trovaCliente src = ();
Console.scriviStringa ("Destination:");
Customer trovaCliente dst = (); if
(src == null == Null) {
Console.scriviStringa ("Customer / s does not exist / i");
return;}
Console.scriviStringa ("What will you transfer?");
Console.leggiIntero int q = (); if
(banca.trasferisci (src.ritornaNumCliente (), dst.ritornaNumCliente (), q)) {
Console.scriviStringa ("Transfer done");} else {
Console.scriviStringa ("Transfer is not performed");}
} / ** Print data bank. * / Private static void
stampaDati () {
Console.scriviStringa (banca.toString ());}
/ ** Print the main menu. * / Private static void
stampaMenuPrincipale () {
Console.scriviStringa (a) add client ");
Console.scriviStringa (b) delete customer");
Console.scriviStringa (c) is the customer ");
Console.scriviStringa (d) tasferisci sum" )
Console.scriviStringa (e) print data bank ");
Console.scriviStringa (f) Exit");}
public static void main (String [] args) {for
(;;){
stampaMenuPrincipale ();
Console.leggiCar char c = ();
switch (c)
{case 'a':
aggiungiCliente ();
break;
case 'b':
eliminaCliente ();
break;
homes 'c':
trovaEStampaCliente ();
break;
case 'd':
trasferisciSomma ();
break;
case 'e':
stampaDati ();
break;
case 'f':
return;
default:
Console.scriviStringa ("non scelta valida ");}
}}}