cola.java

来自「solution to the simulation of the vascul」· Java 代码 · 共 57 行

JAVA
57
字号
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package examen;import java.util.*;/** * * @author ANGEL */public class cola {    LinkedList l;    boolean lectura;    boolean escritura;    int id;    cola(boolean lectura, boolean escritura,int id){        l = new LinkedList();        this.lectura = lectura;        this.escritura = escritura;        this.id = id;    }    void meter(String dato){        if(!dato.equals("") ){            l.offer(dato);        }    }    String sacar(){        String valor = "no hay dato";        try{        valor = (String)l.poll();        }catch(NoSuchElementException e){            valor = "no hay dato";        }        return valor;    }    void recorrer(){        System.out.println("Recorrido Cola "+id +" "+l);    }    void invertir(){        if(lectura){            lectura = false;            escritura = true;        }else if(escritura){            escritura = false;            lectura = true;        }    }    String tipo(){        if(escritura)            return "[escritor]";        else            return "[lector]";    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?