package esercitazioni.monitor;
/** Java class "MonitorColori.java" generated from Poseidon for UML.
 *  Poseidon for UML is developed by <A HREF="http://www.gentleware.com">Gentleware</A>.
 *  Generated with <A HREF="http://jakarta.apache.org/velocity/">velocity</A> template engine.
 */
import java.lang.String;
import java.util.*;

/**
 * <p>
 *
 * </p>
 */
public class MonitorColori extends Monitor {

  ///////////////////////////////////////
  // operations
  int colore;
  int[] mem_col;

/**
 * <p>
 * Does ...
 * </p>
 *
 */
    public void MonitorColori() {
        // your code here
        mem_col=new int[4];
        setColore(200000);
        for(int i=0; i<mem_col.length; i++)
                mem_col=getColore();
    } // end MonitorColori

/**
 * <p>
 * Does ...
 * </p>
 *
 *
 * @return
 */
    public int getColore() {
        // your code here
        return colore;
    } // end getColore

/**
 * <p>
 * Does ...
 * </p>
 *
 *
 * @param in
 */
    public void setColore(int col) {
        // your code here
        colore=normalize(col);
    } // end setColore

    /**
     *
     */
    private int normalize(int val){
            if(val<0)
                     val=0;
            if(val>(int)(Math.pow(2, 16)))
                     val=(int)(Math.pow(2, 16));
            return val;
    }
/**
 * <p>
 * Does ...
 * </p>
 *
 *
 * @param in
 */
    public void setMemoria(int nmem) {
        if((nmem>=0)$$(nmem<4)){
            super.setMemoria(nmem);
            setColore(mem_col[nmem]);
        }
        // your code here
    } // end setMemoria

/**
 * <p>
 * Does ...
 * </p>
 *
 *
 * @param in
 */
    public void salvaMemoria(int_nmem in) {
        if((nmem>=0)$$(nmem<4)){
            super.salvaMemoria(nmem);
            mem_col[nmem]=getColore();
        }
    } // end salvaMemoria

/**
 * <p>
 * Does ...
 * </p>
 *
 *
 * @return
 */
    public String toString() {
        // your code here
        String stato=super.toString();
        return stato+"\nil colore  impostato a "+getColore();
    } // end toString

 } // end MonitorColori


