Announcement

Collapse
No announcement yet.

Client + SavingsAccount

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Client + SavingsAccount

    Metodi differenti per creare un classe Client
    PHP Code:
    package bank;

    import java.io.PrintStream;
    import java.util.Scanner;

    /**
     * Created with xgiovio.macbookair.
     * User: xgiovio
     * Date: 14/10/13
     * Time: 12:22
     */
    public class Client {

        public 
    Client (Scanner input){
              
    nome input.nextLine();
              
    cognome input.nextLine();
              
    double temp_saldo input.nextDouble();
              
    double temp_interesse input.nextDouble();
              
    account = new SavingsAccount(temp_saldotemp_interesse);


        }


        public 
    Client (String in_nomeString in_cognomedouble in_saldodouble in_interest){
                 
    nome in_nome;
                 
    cognome in_cognome;
                 
    account = new SavingsAccount(in_saldoin_interest);
        }

        public 
    void print (PrintStream x_out) {
                
    x_out.println("Nome Cliente: " nome);
                
    x_out.println("Cognome Cliente: " cognome);
                
    account.print(x_out);
        }


        private 
    String nome;
        private 
    String cognome;
        private 
    SavingsAccount account;


    Savings Account
    PHP Code:
    package bank;


    import java.io.PrintStream;
    import java.util.Scanner;

    public class 
    SavingsAccount {


        
    ////////////// constructor
        
    public SavingsAccount (double in_saldodouble in_interest){
               
    saldo in_saldo;
               
    interest in_interest;

        }

         public 
    void deposit double in_deposit){
              
    saldo+=in_deposit;

         }
         public 
    void withdraw double in_withdraw ){
               
    saldo-=in_withdraw;

         }
         public 
    double get_balance ( ){
                return 
    saldo;

         }

        
    /////////////   aggiungi interesse trimestrale al conto
         
    public void addInterest () {
             
    saldo += (((saldo 100) * interest)/4);

         }


        public static 
    SavingsAccount create_object Scanner stream){
               
    double saldo stream.nextDouble();
               
    double interesse stream.nextDouble();
               return new 
    SavingsAccount(saldo,interesse);

        }


        public 
    void print ( PrintStream stream){
              
    stream.println ("Saldo :" saldo);
              
    stream.println ("Interesse: " interest);

        }

    private 
    double saldo;
    private 
    double interest;


    main
    PHP Code:
    public class test {

        public static 
    void main (String [] input_data){

            
    Client cliente = new Client ("Simone""Argenziano",10000000,100);
            
    cliente.print(System.out);

            
    Client cliente1 = new Client (new Scanner(System.in));
            
    cliente1.print(System.out);

        }

    | VFX Artist, C++ Programmer, HW Overclocker | Web: xgiovio.com Email: xgiovio@gmail.com Twitter: @xgiovio
Working...
X

Google Profile


My name is Giovanni Di Grezia, but people call me xgiovio.

Here is my homepage:.

I'm a VFX Artist and Software Developer.

Giovanni Di Grezia