Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package jogo_forca;
- import java.util.Random;
- public class Modelo {
- private int tamanhof;
- private int tamanhor;
- private int sort;
- private int tipo;
- private boolean vel = false;
- private boolean pla = false;
- private boolean rep = false;
- private int falta = 0;
- private int erros = 0;
- private char[] palavra;
- private String res;
- private String dica;
- private String[][] palavras = {
- {"HAMBURGUER", "PIZZA", "BATATA FRITA", "CACHORRO QUENTE", "LASANHA", "MACARRONADA", "ESCONDIDINHO", "STROGONOFF", "REFRIGERANTE", "SUCO DE LARANJA", "SUCO DE GOIABA", "SUCO DE MARACUJA"},
- {"BOLA", "LÁPIS", "CANETA", "BORRACHA", "PANELA", "FOGAO", "GELADEIRA", "PRATO", "PLACA DE REDE", "HARD DISK", "MONITOR", "FONTE DE ALIMENTACAO"}
- };
- private String[] dicas = {"LANCHES", "COMIDAS", "BEBIDAS", "ESCOLAR", "COZINHA", "COMPUTADOR"};
- private char[] let_errada;
- public Modelo() {
- this.let_errada = new char[6];
- }
- public void gerar(int tipo) {
- this.tipo = tipo;
- Random gerador = new Random();
- sort = gerador.nextInt(12);
- tamanhor = palavras[tipo][sort].length();
- res = palavras[tipo][sort];
- let_errada[0] = '\0';
- }
- public void geraTraco() {
- palavra = new char[tamanhor];
- for (int i = 0; i < tamanhor; i++) {
- if (palavras[tipo][sort].charAt(i) != ' ') {
- palavra[i] = '_';
- }
- }
- }
- public void verifica() {
- if (erros == 6) {
- erros = 0;
- falta = 0;
- pla = false;
- } else if (falta == 0) {
- erros = 0;
- pla = true;
- }
- }
- public void procLetra(String letra) {
- rep = false;
- for(int i = 0; i < 6; i++){
- if(let_errada[i]==letra.charAt(0)){
- rep=true;
- }
- }
- for (int i = 0; i < tamanhor; i++) {
- if (palavras[tipo][sort].charAt(i) == letra.charAt(0)) {
- if (palavra[i] == '_') {
- palavra[i] = letra.charAt(0);
- vel = true;
- falta--;
- } else {
- rep = true;
- }
- }
- }
- if (vel == false && rep == false) {
- let_errada[erros] = letra.charAt(0);
- erros++;
- }
- vel = false;
- }
- public void geraDica() {
- if (tipo == 0) {
- if (sort < 4) {
- dica = dicas[0];
- } else if (sort < 8) {
- dica = dicas[1];
- } else if (sort < 12) {
- dica = dicas[2];
- }
- } else if (tipo == 1) {
- if (sort < 4) {
- dica = dicas[3];
- } else if (sort < 8) {
- dica = dicas[4];
- } else if (sort < 12) {
- dica = dicas[5];
- }
- }
- }
- public void calcTamanho() {
- tamanhof = palavras[tipo][sort].length();
- for (int i = 0; i < palavras[tipo][sort].length(); i++) {
- if (palavras[tipo][sort].charAt(i) == ' ') {
- tamanhof--;
- }
- }
- falta = tamanhof;
- }
- public int getTamanhor() {
- return tamanhor;
- }
- public void setTamanhor(int tamanho) {
- this.tamanhor = tamanho;
- }
- public int getTamanhof() {
- return tamanhof;
- }
- public void setTamanhof(int tamanhof) {
- this.tamanhof = tamanhof;
- }
- public int getSort() {
- return sort;
- }
- public void setSort(int sort) {
- this.sort = sort;
- }
- public int getTipo() {
- return tipo;
- }
- public void setTipo(int tipo) {
- this.tipo = tipo;
- }
- public char[] getPalavra() {
- return palavra;
- }
- public void setPalavra(char[] palavra) {
- this.palavra = palavra;
- }
- public String getDica() {
- return dica;
- }
- public void setDica(String dica) {
- this.dica = dica;
- }
- public String getRes() {
- return res;
- }
- public void setRes(String res) {
- this.res = res;
- }
- public boolean isVel() {
- return vel;
- }
- public void setVel(boolean vel) {
- this.vel = vel;
- }
- public boolean isPla() {
- return pla;
- }
- public void setPla(boolean pla) {
- this.pla = pla;
- }
- public int getFalta() {
- return falta;
- }
- public void setFalta(int falta) {
- this.falta = falta;
- }
- public int getErros() {
- return erros;
- }
- public void setErros(int erros) {
- this.erros = erros;
- }
- public char[] getLet_errada() {
- return let_errada;
- }
- public void setLet_errada(char[] let_errada) {
- this.let_errada = let_errada;
- }
- public boolean isRep() {
- return rep;
- }
- public void setRep(boolean rep) {
- this.rep = rep;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment