Game logic
This commit is contained in:
parent
94373bb1b9
commit
4ad82a38b2
12 changed files with 398 additions and 17 deletions
9
.idea/libraries/kibofplib_1_0.xml
generated
Normal file
9
.idea/libraries/kibofplib_1_0.xml
generated
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<component name="libraryTable">
|
||||||
|
<library name="kibofplib-1.0">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$PROJECT_DIR$/lib/kibofplib-1.0.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</component>
|
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="19" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_19" default="true" project-jdk-name="corretto-19" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -7,5 +7,6 @@
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="kibofplib-1.0" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
BIN
lib/kibofplib-1.0.jar
Normal file
BIN
lib/kibofplib-1.0.jar
Normal file
Binary file not shown.
127
src/it/unibs/fp/patenteelibbrettopregoh/GameData.java
Normal file
127
src/it/unibs/fp/patenteelibbrettopregoh/GameData.java
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
package it.unibs.fp.patenteelibbrettopregoh;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class GameData {
|
||||||
|
private final String nomePersonaggio;
|
||||||
|
private final ArrayList<PaginaDiario> diario;
|
||||||
|
private final Comuni comuni;
|
||||||
|
private final ArrayList<Persona> persone;
|
||||||
|
private double saldo;
|
||||||
|
private int numeroMazzetteAccettatePolizia;
|
||||||
|
private int numeroRivoluzionariAccettati;
|
||||||
|
private StatoGioco statoGioco;
|
||||||
|
private int giorno;
|
||||||
|
private int indiceUltimaPersonaPassata;
|
||||||
|
private LocalDate data;
|
||||||
|
|
||||||
|
public GameData(Formato formato) {
|
||||||
|
this.diario = new ArrayList<>();
|
||||||
|
this.comuni = Parser.parseComuni(formato, "FileEsercizio/comuni");
|
||||||
|
this.persone = Parser.parsePersone(formato, "FileEsercizio/IDpersone");
|
||||||
|
this.saldo = 0;
|
||||||
|
this.numeroMazzetteAccettatePolizia = 0;
|
||||||
|
this.numeroRivoluzionariAccettati = 0;
|
||||||
|
this.statoGioco = StatoGioco.IN_CORSO;
|
||||||
|
this.nomePersonaggio = "Ajeje Brazorf";
|
||||||
|
this.giorno = 1;
|
||||||
|
this.indiceUltimaPersonaPassata = -1;
|
||||||
|
this.data = LocalDate.of(2024, 5, giorno);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<PaginaDiario> getDiario() {
|
||||||
|
return diario;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Comuni getComuni() {
|
||||||
|
return comuni;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Persona> getPersone() {
|
||||||
|
return persone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getSaldo() {
|
||||||
|
return saldo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Persona getPersonaDaControlare() {
|
||||||
|
indiceUltimaPersonaPassata++;
|
||||||
|
return persone.get(indiceUltimaPersonaPassata);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNumeroMazzetteAccettatePolizia() {
|
||||||
|
return numeroMazzetteAccettatePolizia;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNumeroRivoluzionariAccettati() {
|
||||||
|
return numeroRivoluzionariAccettati;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPaginaDiario(PaginaDiario pagina) {
|
||||||
|
diario.add(pagina);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addSaldo(double valore) {
|
||||||
|
saldo += valore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void pagaMulta(double valore) {
|
||||||
|
paga(valore);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void incrementaMazzetteAccettatePolizia() {
|
||||||
|
numeroMazzetteAccettatePolizia++;
|
||||||
|
if (numeroMazzetteAccettatePolizia >= 2) {
|
||||||
|
statoGioco = StatoGioco.GIUSTIZIATO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void incrementaRivoluzionariAccettati() {
|
||||||
|
numeroRivoluzionariAccettati++;
|
||||||
|
if (numeroRivoluzionariAccettati >= 5) {
|
||||||
|
statoGioco = StatoGioco.RIVOLUZIONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNomePersonaggio() {
|
||||||
|
return nomePersonaggio;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StatoGioco getStatoGioco() {
|
||||||
|
return statoGioco;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getGiorno() {
|
||||||
|
return giorno;
|
||||||
|
}
|
||||||
|
public void incrementaGiorno(int numeroPersoneControllate) {
|
||||||
|
if (numeroPersoneControllate > 0) {
|
||||||
|
addSaldo(50 * numeroPersoneControllate);
|
||||||
|
}
|
||||||
|
paga(200);
|
||||||
|
|
||||||
|
giorno++;
|
||||||
|
|
||||||
|
data = LocalDate.of(2024, 5, giorno);
|
||||||
|
|
||||||
|
if (giorno > 12 && statoGioco == StatoGioco.IN_CORSO && saldo > 2300) {
|
||||||
|
statoGioco = StatoGioco.DODICESIMO_GIORNO;
|
||||||
|
} else if (giorno > 12 && statoGioco == StatoGioco.IN_CORSO) {
|
||||||
|
statoGioco = StatoGioco.NON_ABBASTANZA_SOLDI;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void paga(double valore) {
|
||||||
|
saldo -= valore;
|
||||||
|
if (saldo < 0) {
|
||||||
|
statoGioco = StatoGioco.ARRESTATO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
36
src/it/unibs/fp/patenteelibbrettopregoh/PaginaDiario.java
Normal file
36
src/it/unibs/fp/patenteelibbrettopregoh/PaginaDiario.java
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
package it.unibs.fp.patenteelibbrettopregoh;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class PaginaDiario {
|
||||||
|
private final String data;
|
||||||
|
private final double bilancio;
|
||||||
|
private final ArrayList<PersonaControllata> personeControllate;
|
||||||
|
|
||||||
|
public PaginaDiario(String data, double bilancio) {
|
||||||
|
this.data = data;
|
||||||
|
this.bilancio = bilancio;
|
||||||
|
this.personeControllate = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getBilancio() {
|
||||||
|
return bilancio;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<PersonaControllata> getPersoneControllate() {
|
||||||
|
return personeControllate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPersonaControllata(PersonaControllata persona) {
|
||||||
|
this.personeControllate.add(persona);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removePersonaControllata(PersonaControllata persona) {
|
||||||
|
this.personeControllate.remove(persona);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -7,15 +7,70 @@ import java.util.ArrayList;
|
||||||
public class Parser {
|
public class Parser {
|
||||||
public static ArrayList<Persona> parsePersone(Formato formato, String fileName) {
|
public static ArrayList<Persona> parsePersone(Formato formato, String fileName) {
|
||||||
ArrayList<Persona> persone = new ArrayList<>();
|
ArrayList<Persona> persone = new ArrayList<>();
|
||||||
// Implement parsing logic here based on the format
|
if (formato == Formato.XML) {
|
||||||
// For example, if formato is JSON, use a JSON library to parse the file
|
fileName = fileName + ".xml";
|
||||||
// and populate the persone list.
|
XMLInputFactory xmlif;
|
||||||
|
XMLStreamReader xmlr;
|
||||||
|
String currentElement = null;
|
||||||
|
String nome = null;
|
||||||
|
String cognome = null;
|
||||||
|
String sesso = null;
|
||||||
|
String dataNascita = null;
|
||||||
|
String comuneNascita = null;
|
||||||
|
String codiceFiscale = null;
|
||||||
|
String scadenzaDocumento = null;
|
||||||
|
|
||||||
|
try (FileInputStream reader = new FileInputStream(fileName)) {
|
||||||
|
xmlif = XMLInputFactory.newInstance();
|
||||||
|
xmlr = xmlif.createXMLStreamReader(fileName, reader);
|
||||||
|
|
||||||
|
while (xmlr.hasNext()) {
|
||||||
|
int event = xmlr.getEventType();
|
||||||
|
switch (event) {
|
||||||
|
case XMLStreamConstants.START_ELEMENT:
|
||||||
|
currentElement = xmlr.getLocalName(); // <- sposta qui, nel posto giusto
|
||||||
|
break;
|
||||||
|
case XMLStreamConstants.CHARACTERS:
|
||||||
|
String text = xmlr.getText().trim();
|
||||||
|
if (!text.isEmpty() && currentElement != null) {
|
||||||
|
switch (currentElement) {
|
||||||
|
case "nome" -> nome = text;
|
||||||
|
case "cognome" -> cognome = text;
|
||||||
|
case "sesso" -> sesso = text;
|
||||||
|
case "data_nascita" -> dataNascita = text;
|
||||||
|
case "comune_nascita" -> comuneNascita = text;
|
||||||
|
case "codice_fiscale" -> codiceFiscale = text;
|
||||||
|
case "scadenza_documento" -> scadenzaDocumento = text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case XMLStreamConstants.END_ELEMENT:
|
||||||
|
String endTag = xmlr.getLocalName();
|
||||||
|
if (endTag.equals("persona")) {
|
||||||
|
Persona persona = new Persona(nome, cognome, sesso, dataNascita, comuneNascita, codiceFiscale, scadenzaDocumento);
|
||||||
|
persone.add(persona);
|
||||||
|
}
|
||||||
|
currentElement = null; // reset solo alla fine di un elemento
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
xmlr.next(); // importante: avanza solo una volta per ciclo
|
||||||
|
}
|
||||||
|
xmlr.close();
|
||||||
|
} catch (FactoryConfigurationError | XMLStreamException | IOException e) {
|
||||||
|
System.out.println("Error reading the file: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fileName = fileName + ".json";
|
||||||
|
}
|
||||||
return persone;
|
return persone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Comuni parseComuni(Formato formato, String fileName) {
|
public static Comuni parseComuni(Formato formato, String fileName) {
|
||||||
Comuni comuni = new Comuni();
|
Comuni comuni = new Comuni();
|
||||||
if (formato == Formato.XML) {
|
if (formato == Formato.XML) {
|
||||||
|
fileName = fileName + ".xml";
|
||||||
XMLInputFactory xmlif;
|
XMLInputFactory xmlif;
|
||||||
XMLStreamReader xmlr;
|
XMLStreamReader xmlr;
|
||||||
String currentElement = null;
|
String currentElement = null;
|
||||||
|
@ -67,11 +122,15 @@ public class Parser {
|
||||||
} catch (FactoryConfigurationError | XMLStreamException | IOException e) {
|
} catch (FactoryConfigurationError | XMLStreamException | IOException e) {
|
||||||
System.out.println("Error reading the file: " + e.getMessage());
|
System.out.println("Error reading the file: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (formato == Formato.JSON) {
|
else {
|
||||||
// Implement XML parsing logic here
|
fileName = fileName + ".json";
|
||||||
// For example, use an XML library to read the file and populate the comuni list
|
|
||||||
}
|
}
|
||||||
return comuni;
|
return comuni;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void saveDiario (String fileName, ArrayList<PaginaDiario> pagineDiario, Formato formato) {
|
||||||
|
// non so ancora come fare
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,113 @@
|
||||||
package it.unibs.fp.patenteelibbrettopregoh;
|
package it.unibs.fp.patenteelibbrettopregoh;
|
||||||
|
|
||||||
|
import it.kibo.fp.lib.InputData;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class PatenteELibbrettoPregohMain {
|
public class PatenteELibbrettoPregohMain {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println("PatenteELibbrettoPregoh!");
|
System.out.println("PatenteELibbrettoPregoh!");
|
||||||
|
Formato formato = getFormato();
|
||||||
|
System.out.println();
|
||||||
|
GameData gameData = new GameData(formato);
|
||||||
|
|
||||||
Comuni comuni = Parser.parseComuni(Formato.XML, "FileEsercizio/comuni.xml");
|
while (gameData.getStatoGioco() == StatoGioco.IN_CORSO) {
|
||||||
//ArrayList<Persona> persone = Parser.parsePersone(Formato.JSON, "persone.txt");
|
int personeChePassano = ((int)(Math.random() * 5) + 3);
|
||||||
Persona p = new Persona("Mario", "Rossi", "M", "1980-01-01", "Roma", "", "2005-01-15");
|
System.out.println("Il giorno " + gameData.getData() + " passeranno " + personeChePassano + " persone");
|
||||||
System.out.println(p.calcolaCodiceFiscale(comuni));
|
ArrayList<PersonaControllata> personeControllate = new ArrayList<>();
|
||||||
|
for (int i = 0; i < personeChePassano; i++) {
|
||||||
|
if (gameData.getStatoGioco() == StatoGioco.IN_CORSO) {
|
||||||
|
Persona personaDaControllare = gameData.getPersonaDaControlare();
|
||||||
|
boolean esito = controllaPersona(personaDaControllare, gameData.getComuni(), gameData);
|
||||||
|
boolean accettata = InputData.readYesOrNo("Si presenta\n" + personaDaControllare + "\nC.F. calcolato: " + personaDaControllare.calcolaCodiceFiscale(gameData.getComuni()) + "\nAccettare");
|
||||||
|
if (accettata) {
|
||||||
|
if (esito){
|
||||||
|
System.out.println("La persona aveva i dati corretti");
|
||||||
|
PersonaControllata personaControllata = new PersonaControllata(personaDaControllare, true, TipoPersonaControllata.PERSONA_NORMALE);
|
||||||
|
personeControllate.add(personaControllata);
|
||||||
|
} else {
|
||||||
|
System.out.println("La persona aveva i dati errati");
|
||||||
|
PersonaControllata personaControllata = new PersonaControllata(personaDaControllare, true, TipoPersonaControllata.PERSONA_NORMALE);
|
||||||
|
personeControllate.add(personaControllata);
|
||||||
|
if (Math.random() < 0.5){
|
||||||
|
System.out.println("Sei stato fortunato, non hai presso la multa");
|
||||||
|
} else {
|
||||||
|
System.out.println("Hai preso una multa da 300§");
|
||||||
|
gameData.pagaMulta(300);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (esito) {
|
||||||
|
System.out.println("La persona aveva i dati corretti ... come sei salato");
|
||||||
|
PersonaControllata personaControllata = new PersonaControllata(personaDaControllare, false, TipoPersonaControllata.PERSONA_NORMALE);
|
||||||
|
personeControllate.add(personaControllata);
|
||||||
|
if (Math.random() < 0.5){
|
||||||
|
System.out.println("Sei stato fortunato, non hai presso la multa");
|
||||||
|
} else {
|
||||||
|
System.out.println("Hai preso una multa da 150§");
|
||||||
|
gameData.pagaMulta(150);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
System.out.println("La persona aveva i dati errati");
|
||||||
|
PersonaControllata personaControllata;
|
||||||
|
|
||||||
|
if (Math.random() < 0.4){
|
||||||
|
int mazzetta = ((int)((Math.random() * 251))) + 250;
|
||||||
|
System.out.println(personaDaControllare.getNome() + " " + personaDaControllare.getCognome() + " prova a corromperti con " + mazzetta + "§");
|
||||||
|
boolean accettataMazzetta = InputData.readYesOrNo("Accettare la mazzetta");
|
||||||
|
if (accettataMazzetta){
|
||||||
|
gameData.addSaldo(mazzetta);
|
||||||
|
if (Math.random() < 0.7){
|
||||||
|
System.out.println("Hai accettato la mazzetta, ti è andata bene ... era un rivoluzionario");
|
||||||
|
gameData.incrementaRivoluzionariAccettati();
|
||||||
|
personaControllata = new PersonaControllata(personaDaControllare, true, TipoPersonaControllata.RIVOLUZIONARIO);
|
||||||
|
} else {
|
||||||
|
System.out.println("Hai accettato la mazzetta ... era un poliziotto");
|
||||||
|
gameData.incrementaMazzetteAccettatePolizia();
|
||||||
|
gameData.pagaMulta(gameData.getSaldo() * 0.6);
|
||||||
|
personaControllata = new PersonaControllata(personaDaControllare, true, TipoPersonaControllata.POLIZIOTTO);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
personaControllata = new PersonaControllata(personaDaControllare, false, TipoPersonaControllata.PERSONA_NORMALE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
personaControllata = new PersonaControllata(personaDaControllare, false, TipoPersonaControllata.PERSONA_NORMALE);
|
||||||
|
}
|
||||||
|
personeControllate.add(personaControllata);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gameData.incrementaGiorno(personeControllate.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (gameData.getStatoGioco()){
|
||||||
|
case ARRESTATO -> System.out.println("Sei stato arrestato");
|
||||||
|
case GIUSTIZIATO -> System.out.println("Sei stato giustiziato");
|
||||||
|
case RIVOLUZIONE -> System.out.println("Hai vinto la rivoluzione");
|
||||||
|
case DODICESIMO_GIORNO -> System.out.println("Hai vinto, sei sopravvissuto 12 giorni");
|
||||||
|
case NON_ABBASTANZA_SOLDI -> System.out.println("Non hai abbastanza soldi");
|
||||||
|
default -> System.out.println("Hai perso");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean controllaPersona(Persona persona, Comuni comuni, GameData gameData) {
|
||||||
|
return persona.isCodiceFiscaleValido(comuni) && persona.isDocumentoValido(gameData.getData());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Formato getFormato() {
|
||||||
|
Formato formato = null;
|
||||||
|
|
||||||
|
int sceltaFormato = InputData.readIntegerBetween("Inserisci il formato (0: JSON, 1: XML): ", 0, 1);
|
||||||
|
if (sceltaFormato == 0) {
|
||||||
|
System.out.println("Hai scelto il formato JSON");
|
||||||
|
formato = Formato.JSON;
|
||||||
|
} else {
|
||||||
|
System.out.println("Hai scelto il formato XML");
|
||||||
|
formato = Formato.XML;
|
||||||
|
}
|
||||||
|
return formato;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package it.unibs.fp.patenteelibbrettopregoh;
|
package it.unibs.fp.patenteelibbrettopregoh;
|
||||||
|
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
public class Persona {
|
public class Persona {
|
||||||
private final String nome;
|
private final String nome;
|
||||||
|
@ -208,11 +212,9 @@ public class Persona {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDocumentoValido(LocalDate date) {
|
||||||
|
LocalDate scadenza = LocalDate.parse(scadenzaDocumento);
|
||||||
public boolean isScadenzaDocumentoValido(){
|
return date.isBefore(scadenza) || date.isEqual(scadenza);
|
||||||
// Implement logic to validate the expiration date of the document
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isVocale(char c) {
|
private static boolean isVocale(char c) {
|
||||||
|
@ -241,4 +243,9 @@ public class Persona {
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return nome + " " + cognome + " (" + sesso + ") nato il " + dataNascita + " a " + comuneNascita + " con C.F. " + codiceFiscale + ", validità documento " + scadenzaDocumento;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
package it.unibs.fp.patenteelibbrettopregoh;
|
||||||
|
|
||||||
|
public class PersonaControllata extends Persona {
|
||||||
|
private final boolean esitoControllo;
|
||||||
|
private final TipoPersonaControllata tipoPersonaControllata;
|
||||||
|
|
||||||
|
public PersonaControllata(Persona persona, boolean esitoControllo, TipoPersonaControllata tipoPersonaControllata) {
|
||||||
|
super(persona.getNome(), persona.getCognome(), persona.getSesso(), persona.getDataNascita(), persona.getComuneNascita(), persona.getCodiceFiscale(), persona.getScadenzaDocumento());
|
||||||
|
this.esitoControllo = esitoControllo;
|
||||||
|
this.tipoPersonaControllata = tipoPersonaControllata;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEsitoControllo() {
|
||||||
|
return esitoControllo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TipoPersonaControllata getTipoPersonaControllata() {
|
||||||
|
return tipoPersonaControllata;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Nome: " + getNome() + "\n" +
|
||||||
|
"Cognome: " + getCognome() + "\n" +
|
||||||
|
"Sesso: " + getSesso() + "\n" +
|
||||||
|
"Data di Nascita: " + getDataNascita() + "\n" +
|
||||||
|
"Comune di Nascita: " + getComuneNascita() + "\n" +
|
||||||
|
"Codice Fiscale: " + getCodiceFiscale() + "\n" +
|
||||||
|
"Scadenza Documento: " + getScadenzaDocumento() + "\n" +
|
||||||
|
"Esito Controllo: " + (esitoControllo ? "Positivo" : "Negativo") + "\n" +
|
||||||
|
"Tipo Persona Controllata: " + tipoPersonaControllata.toString() + "\n";
|
||||||
|
}
|
||||||
|
}
|
5
src/it/unibs/fp/patenteelibbrettopregoh/StatoGioco.java
Normal file
5
src/it/unibs/fp/patenteelibbrettopregoh/StatoGioco.java
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
package it.unibs.fp.patenteelibbrettopregoh;
|
||||||
|
|
||||||
|
public enum StatoGioco {
|
||||||
|
ARRESTATO, GIUSTIZIATO, RIVOLUZIONE, DODICESIMO_GIORNO, NON_ABBASTANZA_SOLDI, IN_CORSO;
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package it.unibs.fp.patenteelibbrettopregoh;
|
||||||
|
|
||||||
|
public enum TipoPersonaControllata {
|
||||||
|
RIVOLUZIONARIO, POLIZIOTTO, PERSONA_NORMALE;
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue