/*
  Copyright (C) 2013 Alessandro Bugatti (alessandro.bugatti@istruzione.it)

  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
  as published by the Free Software Foundation; either version 2
  of the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

/**
 *  Classe semplice per gestire un conto corrente
 *  con le operazioni di creazione, accredito, addebito e saldo
 *  \author Alessandro Bugatti
 *
 *  version 0.1
 *  date  Creazione  07/03/2009
 *  date  Ultima modifica 02/10/2013
 *
 */


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package contocorrentemenu;

/**
 * Classe semplice per gestire un conto corrente
 * con le operazioni di creazione, accredito, addebito e saldo
 *  
 @author Alessandro Bugatti
 */
public class ContoCorrente {
    String codice;
    String nome;
    String cognome;
    double capitale;
    
    private String generaCodice()
    {
        return "000000";
    }

    /**
     * Costruisce un oggetto con nome e cognome, creando in automatico un codice
     * attualmente fittizio e posto a 0000000 e settando il saldo a zero.
     @param n Nome
     @param c Cognome
     */
    public ContoCorrente(String nString c)
    {
        nome n;
        cognome c;
        codice generaCodice();
        capitale 0;
    }
    
    /**
     * Peremtte di versare sul conto una certa quantità di soldi
     @param d Soldi da depositare
     */
    public void deposito (double d)
    {
        capitale += d;
    }
    
    /**
     * Permette di prelevare una certa quantità di soldi.
     * Se i soldi da prelevare sono di più di quelli disponibili 
     * non viene prelevato niente
     @param p Soldi da prelevare
     @return True se l'operazione è andata a buon fine, false altrimenti
     */
    public boolean prelievo (double p)
    {
        if (<= capitale)
        {
            capitale -= p;
            return true;
        }
        else
            return false;
    }
    
    /**
     * Restituisce il saldo del conto corrente
     @return Salso
     */
    public double saldo()
    {
        return capitale;
    }
    
    /**
     * Ritorna il nominativo formato da  cognome e nome separati da spazio
     @return il nominativo
     */
    public String getNominativo()
    {
        return cognome " " nome;
    }
}