Advertisement
wellison1

Untitled

Oct 21st, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.23 KB | None | 0 0
  1. import java.util.Scanner;
  2. class Lista3{
  3.     private String nome;
  4.     private Lista3 proximo;
  5.    public Lista3(){
  6.        this.nome = null;
  7.        this.proximo = null;
  8.    }
  9.    //INSERE OS NOMES NA LISTA
  10.    public void inserir(String nome){
  11.        if (this.proximo==null){
  12.           this.nome = nome;
  13.           this.proximo = new Lista3();
  14.        } else{
  15.            this.proximo.inserir(nome);
  16.        }
  17.    }
  18.    //IMPRIMI TODOS OS NOMES QUE ESTÃO NA LISTA ATUALMENTE
  19.    public String imprimirTudo (String nome){
  20.        String aux = "";
  21.        if (!nome.equals(null)){
  22.            aux += this.nome + "\n";
  23.        }else{
  24.            aux += "";
  25.        }
  26.        return aux;
  27.    }
  28.     //VERIFICA SE O NOME ESTÁ NA LISTA
  29.   public  boolean existe (String nome){
  30.        boolean aux = false;
  31.       if (!this.nome.equals(null) && this.nome.equals(nome)){
  32.           aux = true;
  33.       } else if (!this.proximo.equals(null)){
  34.           this.proximo.existe(nome);
  35.       }else {
  36.           aux = false;
  37.       }
  38.        return  aux;
  39.   }
  40.  
  41.     //RETORNA UM NOME ESPECIFICO QUE O ÚSUARIO QUER
  42.    public String imprimirNome (String nome){
  43.        String aux = "";
  44.        if (this.nome.equals(nome)){
  45.            aux = this.nome;
  46.        } else {
  47.            this.proximo.imprimirNome(nome);
  48.        }
  49.        return aux;
  50.    }
  51.    public String remover (String nome){
  52.        String aux = "";
  53.        if (this.proximo != null){
  54.            if (this.nome.equals(nome)){
  55.                this.nome = this.proximo.nome;
  56.                this.proximo = this.proximo.proximo;
  57.            }else {
  58.                this.proximo.remover(nome);
  59.            }
  60.        }
  61.        return this.nome;
  62.    }
  63.  
  64. }
  65.  
  66. public class Tardis {
  67.     public static void main (String [] args){
  68.         Scanner in = new Scanner(System.in);
  69.        Lista3 lista = new Lista3();
  70.         String comando = "";
  71.         String nome = "";
  72.         String inimigo = in.nextLine();
  73.         String auxiliar[] = inimigo.split(" ");
  74.  
  75.         while (in.hasNext()){
  76.             inimigo = in.next();
  77.             comando = in.next();
  78.             if (comando.equals("ENTRAR") || comando.equals("SAIR") || comando.equals("VERIFICAR")){
  79.             nome = in.nextLine();
  80.             }
  81.         }
  82.     }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement