Announcement

Collapse
No announcement yet.

DistributoreBibite

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

  • DistributoreBibite

    main
    PHP Code:
    import distributori.*;

    /**
     * Created with xgiovio.macbookair.
     * User: xgiovio
     * Date: 23/09/13
     * Time: 14:57
     */


    public class test {

        public static 
    void main (String [] input_data){

                
    DistributoreBibite macchinario = new DistributoreBibite ();

                    
    int ricaricato 0;

                
    System.out.println(macchinario.dammi_bottiglia() );
                    
    ricaricato macchinario.riempi(34);
                
    System.out.println(ricaricato);
                    
    ricaricato macchinario.riempi(15);
                
    System.out.println(ricaricato);
                
    System.out.println(macchinario.stat_bottiglie());
                
    System.out.println(macchinario.stat_gettoni());

                    
    System.out.println(macchinario.dammi_bottiglia());
                
    System.out.println(macchinario.stat_bottiglie());
                
    System.out.println(macchinario.stat_gettoni());


        }

    class
    PHP Code:
    package distributori;

    /**
     * Created with xgiovio.macbookair.
     * User: xgiovio
     * Date: 07/10/13
     * Time: 13:20
     */
    public class DistributoreBibite {

        public 
    int riempi (int n){
            
    int liberi;
                
    liberi max_lattine n_lattine;
                   if  (
    <= liberi ){
                        
    n_lattine += n;
                        return 
    n;
                   }else{
                       
    n_lattine max_lattine;
                        return 
    liberi;
                   }
        }

        public 
    int dammi_bottiglia (){

            if (
    n_lattine == 0)
                return 
    1;
            --
    n_lattine;
            ++
    n_gettoni;
            return 
    0;

        }

        public 
    int stat_bottiglie (){
            return 
    n_lattine;
        }

        public 
    int stat_gettoni(){
            return 
    n_gettoni;
        }


        private 
    int n_lattine 0;
        private 
    int n_gettoni 0;

        private 
    int max_lattine 100;




    | 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