commit 0c5831809bf2be430a186a5b2758c64808caf15c Author: La Programmatrice Verde Date: Thu Nov 13 13:03:57 2025 +0100 Initial Commit diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..e7c4599 --- /dev/null +++ b/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project VerificaNovembre_B_Bassanetti. + + + diff --git a/manifest.mf b/manifest.mf new file mode 100644 index 0000000..1574df4 --- /dev/null +++ b/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml new file mode 100644 index 0000000..782a154 --- /dev/null +++ b/nbproject/build-impl.xml @@ -0,0 +1,1771 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties new file mode 100644 index 0000000..641ee53 --- /dev/null +++ b/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=b11b056a +build.xml.script.CRC32=2f059602 +build.xml.stylesheet.CRC32=f85dc8f2@1.116.0.48 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=b11b056a +nbproject/build-impl.xml.script.CRC32=6c14a5ec +nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.116.0.48 diff --git a/nbproject/private/private.properties b/nbproject/private/private.properties new file mode 100644 index 0000000..bbfa6c1 --- /dev/null +++ b/nbproject/private/private.properties @@ -0,0 +1 @@ +user.properties.file=/home/Verde/.netbeans/27/build.properties diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..e362ed5 --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,86 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processor.options= +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.modulepath=\ + ${run.modulepath} +debug.test.classpath=\ + ${run.test.classpath} +debug.test.modulepath=\ + ${run.test.modulepath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/VerificaNovembre_B_Bassanetti.jar +dist.javadoc.dir=${dist.dir}/javadoc +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=true +javac.modulepath= +javac.processormodulepath= +javac.processorpath=\ + ${javac.classpath} +javac.source=1.8 +javac.target=1.8 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.modulepath=\ + ${javac.modulepath} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +main.class=b_bassanetti.B_Bassanetti +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.modulepath=\ + ${javac.modulepath} +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +run.test.modulepath=\ + ${javac.test.modulepath} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..10dba85 --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + VerificaNovembre_B_Bassanetti + + + + + + + + + diff --git a/src/b_bassanetti/B_Bassanetti.java b/src/b_bassanetti/B_Bassanetti.java new file mode 100644 index 0000000..3fc836a --- /dev/null +++ b/src/b_bassanetti/B_Bassanetti.java @@ -0,0 +1,589 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package b_bassanetti; + +import java.util.InputMismatchException; +import java.util.Scanner; + +/** + * + * @author alunno + */ +public class B_Bassanetti { + + /** + * @param args the command line arguments + */ + static Scanner sc = new Scanner(System.in); + + public static void main(String[] args) { + int scelta = -1; + String sceltaCancellazione; + Trecce trecce[] = null; + boolean isTrecceEmpty = true; + boolean error; + BoxTrecce box; + boolean doesBoxTrecceExist = false; + + do { + System.out.println("Inserire un'opzione:"); + System.out.println("1. Inserire le trecce profumate"); + System.out.println("2. Stampare tutte le trecce di una forma"); + System.out.println("3. Modificare i costi dei Trecce di una forma di una %"); + System.out.println("4. Visualizzare quali Trecce utilizzano il colore viola"); + System.out.println("5. Creare un BoxTrecce"); + System.out.println("6. Mostra BoxTrecce"); + System.out.println("0. Esci"); + System.out.print("Scelta: "); + + try { + scelta = sc.nextInt(); + sc.nextLine(); + switch (scelta) { + case 0: + break; + case 1: + if (isTrecceEmpty) { + trecce = inserisciTrecce(); + System.out.println("Tutte le trecce sono state inserite con successo."); + isTrecceEmpty = false; + } else { + do { + error = false; + System.out.println("Attenzione: procedendo si cancelleranno le precedenti trecce."); + System.out.print("Si vuole proseguire [S/N]? "); + sceltaCancellazione = sc.nextLine().trim().toLowerCase(); + + switch (sceltaCancellazione) { + case "s": + trecce = inserisciTrecce(); + System.out.println("Tutte le trecce sono state inserite con successo."); + case "n": + break; + default: + System.out.println("Errore: scelta non valida."); + pausa(); + error = true; + break; + } + } while (error); + } + pausa(); + break; + case 2: + if (!isTrecceEmpty) { + stampaTreccePerForma(trecce); + } else { + System.out.println("Errore: è necessario inserire le trecce prima di stamparle."); + } + pausa(); + break; + case 3: + if (!isTrecceEmpty) { + modificaPrezzoPercentuale(trecce); + System.out.println("Il prezzo è stato odificato correttamente."); + } else { + System.out.println("Errore: è necessario inserire le trecce prima di modificarne il prezzo."); + } + pausa(); + break; + case 4: + if (!isTrecceEmpty) { + stampaTreccePerColore(trecce); + } else { + System.out.println("Errore: è necessario inserire le trecce prima di stamparle."); + } + pausa(); + break; + case 5: + if (!doesBoxTrecceExist) { + if (doesBoxTrecceExist) { + box = creaBoxTrecce(trecce); + System.out.println("Il box è stato creato con successo."); + doesBoxTrecceExist = false; + } else { + do { + error = false; + System.out.println("Attenzione: procedendo si cancellerà il box precedente."); + System.out.print("Si vuole proseguire [S/N]? "); + sceltaCancellazione = sc.nextLine().trim().toLowerCase(); + + switch (sceltaCancellazione) { + case "s": + box = creaBoxTrecce(trecce); + System.out.println("Il box è stato creato con successo."); + case "n": + break; + default: + System.out.println("Errore: scelta non valida."); + pausa(); + error = true; + break; + } + } while (error); + } + } else { + System.out.println("Errore: è necessario inserire le trecce prima di creare un box."); + } + pausa(); + break; + case 6: + + pausa(); + break; + default: + System.out.println("Errore: scelta non valida."); + pausa(); + break; + } + } catch (InputMismatchException e) { + System.out.println("Errore: scelta non valida."); + pausa(); + } + } while (scelta != 0); + } + + static void pausa() { + System.out.println("Prememe un tasto per continuare. . ."); + sc.nextLine(); + } + + static Trecce[] inserisciTrecce() { + boolean error; + int numeroTrecce; + int codice; + String nome; + String forma; + String colore; + double costo; + int scelta = -1; + + numeroTrecce = numeroTrecce(); + Trecce ritorno[] = new Trecce[numeroTrecce]; + + for (int i = 0; i < numeroTrecce; i++) { + codice = codice(); + + System.out.print("Inserire il nome della treccia: "); + nome = sc.nextLine().trim(); + + System.out.print("Inserire la forma della treccia: "); + forma = sc.nextLine().trim(); + + System.out.print("Inserire il colore della treccia: "); + colore = sc.nextLine().trim().toLowerCase(); + + costo = costo(); + + do { + error = false; + + System.out.println("Di che tipologia è la treccia? "); + System.out.println("1. Piccola"); + System.out.println("2. Media"); + System.out.println("3. Grande"); + System.out.print("Scelta: "); + + try { + scelta = sc.nextInt(); + sc.nextLine(); + switch (scelta) { + case 1: + ritorno[i] = piccola(codice, nome, forma, colore, costo); + break; + case 2: + ritorno[i] = media(codice, nome, forma, colore, costo); + break; + case 3: + ritorno[i] = grande(codice, nome, forma, colore, costo); + break; + } + } catch (InputMismatchException e) { + System.out.println("Scelta non valida."); + pausa(); + error = true; + } + } while (error); + + System.out.println("Treccia inserita con successo."); + pausa(); + } + return ritorno; + } + + static int numeroTrecce() { + boolean error; + int ritorno = -1; + do { + try { + error = false; + System.out.print("Quante trecce inserire? "); + ritorno = sc.nextInt(); + + if (ritorno <= 0) { + System.out.println("Errore: il numero di trecce deve essere un numero maggiore di zero."); + pausa(); + error = true; + } + } catch (InputMismatchException e) { + System.out.println("Numero non valido."); + pausa(); + error = true; + } + + } while (error); + return ritorno; + } + + static int codice() { + boolean error; + int ritorno = -1; + do { + try { + error = false; + System.out.print("Inserisci il codice: "); + ritorno = sc.nextInt(); + sc.nextLine(); + + if (ritorno <= 0) { + System.out.println("Errore: il codice deve essere un numero maggiore di zero."); + pausa(); + error = true; + } + } catch (InputMismatchException e) { + System.out.println("Codice non valido."); + pausa(); + error = true; + } + + } while (error); + return ritorno; + } + + static double costo() { + boolean error; + double ritorno = -1; + do { + try { + error = false; + System.out.print("Inserisci il prezzo: "); + ritorno = sc.nextDouble(); + sc.nextLine(); + + if (ritorno <= 0) { + System.out.println("Errore: il prezzo deve essere un numero maggiore di zero."); + pausa(); + error = true; + } + } catch (InputMismatchException e) { + System.out.println("Prezzo non valido."); + pausa(); + error = true; + } + + } while (error); + return ritorno; + } + + static Piccola piccola(int codice, String nome, String forma, String colore, double costo) { + Piccola ritorno; + String tipoCera; + String tipoFiore; + + System.out.print("Inserire il tipo di cera: "); + tipoCera = sc.nextLine().trim().toLowerCase(); + + System.out.print("Inserire il tipo di fiore: "); + tipoFiore = sc.nextLine().trim().toLowerCase(); + + ritorno = new Piccola(codice, nome, forma, colore, costo, tipoCera, tipoFiore); + + return ritorno; + } + + static Media media(int codice, String nome, String forma, String colore, double costo) { + Media ritorno; + String tipoLegno; + String tipoFiocco; + + System.out.print("Inserire il tipo di legno: "); + tipoLegno = sc.nextLine().trim().toLowerCase(); + + System.out.print("Inserire il tipo di fiocco: "); + tipoFiocco = sc.nextLine().trim().toLowerCase(); + + ritorno = new Media(codice, nome, forma, colore, costo, tipoLegno, tipoFiocco); + + return ritorno; + } + + static Grande grande(int codice, String nome, String forma, String colore, double costo) { + Grande ritorno; + String tipoPalline; + String tipoNastro; + + System.out.print("Inserire il tipo di palline: "); + tipoPalline = sc.nextLine().trim().toLowerCase(); + + System.out.print("Inserire il tipo di nastro: "); + tipoNastro = sc.nextLine().trim().toLowerCase(); + + ritorno = new Grande(codice, nome, forma, colore, costo, tipoPalline, tipoNastro); + + return ritorno; + } + + static void stampaTreccePerForma(Trecce[] trecce) { + int scelta = -1; + boolean error; + + do { + error = false; + System.out.println("Di che forma mostrare le trecce? "); + System.out.println("1. Piccola"); + System.out.println("2. Media"); + System.out.println("3. Grande"); + System.out.print("Scelta: "); + + try { + scelta = sc.nextInt(); + sc.nextLine(); + + switch (scelta) { + case 1: + break; + case 2: + break; + case 3: + break; + default: + System.out.println("Errore: scelta non valida."); + pausa(); + error = true; + } + } catch (InputMismatchException e) { + System.out.println("Errore: scelta non valida."); + pausa(); + error = true; + } + } while (error); + + for (Trecce treccia : trecce) { + switch (scelta) { + case 1: + if (treccia instanceof Piccola) { + System.out.println(treccia.toString()); + } + break; + case 2: + if (treccia instanceof Media) { + System.out.println(treccia.toString()); + } + break; + case 3: + if (treccia instanceof Grande) { + System.out.println(treccia.toString()); + } + break; + } + } + } + + static void modificaPrezzoPercentuale(Trecce[] trecce) { + boolean error; + int scelta = -1; + int tipoTreccia; + boolean direzione = true;//true = aumenta + //false = decrementa + double percentuale; + do { + error = false; + + System.out.println("Di che tipologia è la treccia? "); + System.out.println("1. Piccola"); + System.out.println("2. Media"); + System.out.println("3. Grande"); + System.out.print("Scelta: "); + + try { + scelta = sc.nextInt(); + sc.nextLine(); + switch (scelta) { + case 1: + tipoTreccia = scelta; + break; + case 2: + tipoTreccia = scelta; + break; + case 3: + tipoTreccia = scelta; + break; + default: + System.out.println("Scelta non valida."); + pausa(); + error = true; + } + } catch (InputMismatchException e) { + System.out.println("Scelta non valida."); + pausa(); + error = true; + } + } while (error); + + do { + error = false; + + System.out.println("Come modificare il prezzo? "); + System.out.println("1. Aumento"); + System.out.println("2. Diminuzione"); + System.out.print("Scelta: "); + + try { + scelta = sc.nextInt(); + sc.nextLine(); + switch (scelta) { + case 1: + direzione = true; + break; + case 2: + direzione = false; + break; + default: + System.out.println("Scelta non valida."); + pausa(); + error = true; + } + } catch (InputMismatchException e) { + System.out.println("Scelta non valida."); + pausa(); + error = true; + } + } while (error); + + percentuale = percentuale(); + + for (Trecce treccia : trecce) { + switch (scelta) { + case 1: + if (treccia instanceof Piccola) { + treccia.aggiornaCosto(direzione, percentuale); + } + break; + case 2: + if (treccia instanceof Media) { + treccia.aggiornaCosto(direzione, percentuale); + } + break; + case 3: + if (treccia instanceof Grande) { + treccia.aggiornaCosto(direzione, percentuale); + } + break; + } + } + } + + static double percentuale() { + boolean error; + double ritorno = -1; + do { + try { + error = false; + System.out.print("Inserisci la percentuale: "); + ritorno = sc.nextDouble(); + sc.nextLine(); + + if (ritorno <= 0) { + System.out.println("Errore: la percentuale deve essere un numero maggiore di zero."); + pausa(); + error = true; + } + } catch (InputMismatchException e) { + System.out.println("Percentuale non valida."); + pausa(); + error = true; + } + + } while (error); + return ritorno; + } + + static void stampaTreccePerColore(Trecce[] trecce) { + final String colore = "viola"; + + for (Trecce treccia : trecce) { + if (treccia.getColore().equals(colore)) { + System.out.println(treccia.toString()); + } + } + } + + static BoxTrecce creaBoxTrecce(Trecce[] trecce){ + int prima; + int seconda; + int terza; + int quarta; + String nome; + BoxTrecce ritorno; + Trecce trecceBox[] = new Trecce[4]; + + System.out.println("Inserire il nome del box: "); + nome = sc.nextLine().trim(); + + System.out.println("Trecce disponibili: "); + for (int i = 0; i < trecce.length; i++) { + System.out.println("Treccia numero " + i + ":"); + System.out.println(trecce[i].toString()); + } + + System.out.print("Scegliere la prima treccia: "); + prima = numeroTreccia(trecce.length); + + System.out.print("Scegliere la prima treccia: "); + seconda = numeroTreccia(trecce.length); + + System.out.print("Scegliere la prima treccia: "); + terza = numeroTreccia(trecce.length); + + System.out.print("Scegliere la prima treccia: "); + quarta = numeroTreccia(trecce.length); + + trecceBox[0] = trecce[prima]; + trecceBox[1] = trecce[seconda]; + trecceBox[2] = trecce[terza]; + trecceBox[3] = trecce[quarta]; + + ritorno = new BoxTrecce(nome, trecceBox); + + return ritorno; + } + + static int numeroTreccia(int limite) { + boolean error; + int ritorno = -1; + do { + try { + error = false; + ritorno = sc.nextInt(); + sc.nextLine(); + + if (ritorno < 0 || ritorno >= limite) { + System.out.println("Errore: la treccia deve essere compresa tra zero e " + limite + "."); + pausa(); + error = true; + } + } catch (InputMismatchException e) { + System.out.println("Scelta non valida."); + pausa(); + error = true; + } + + } while (error); + return ritorno; + } + + // static void mostraBoxTrecce +} diff --git a/src/b_bassanetti/BoxTrecce.java b/src/b_bassanetti/BoxTrecce.java new file mode 100644 index 0000000..b044bd1 --- /dev/null +++ b/src/b_bassanetti/BoxTrecce.java @@ -0,0 +1,39 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package b_bassanetti; + +/** + * + * @author alunno + */ +public class BoxTrecce { + String nomeBoxTrecce; + Trecce proposta[] = new Trecce[4]; + + public BoxTrecce(String nomeBox, Trecce[] proposta){ + this.nomeBoxTrecce = nomeBox; + this.proposta = proposta; + } + + public double CalcolaCosto(){ + double ritorno = 0; + for(Trecce treccia: this.proposta){ + ritorno += treccia.getCosto(); + } + + ritorno += (ritorno * 50) / 100; + + return ritorno; + } + + public String getNomeBoxTrecce() { + return nomeBoxTrecce; + } + + public Trecce[] getProposta() { + return proposta; + } +} diff --git a/src/b_bassanetti/Grande.java b/src/b_bassanetti/Grande.java new file mode 100644 index 0000000..19c5748 --- /dev/null +++ b/src/b_bassanetti/Grande.java @@ -0,0 +1,28 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package b_bassanetti; + +/** + * + * @author alunno + */ +public class Grande extends Trecce { + String tipoPalline; + String tipoNastro; + + public Grande(int codice, String nome, String forma, String colore, double costo, String tipoPalline, String tipoNastro){ + super(codice, nome, forma, colore, costo); + this.tipoPalline = tipoPalline; + this.tipoNastro = tipoNastro; + } + + @Override + public String toString(){ + return super.toString() + + "\nTipo palline: " + this.tipoPalline + + "\nTipo fiore: " + this.tipoNastro; + } +} diff --git a/src/b_bassanetti/Media.java b/src/b_bassanetti/Media.java new file mode 100644 index 0000000..e5df57d --- /dev/null +++ b/src/b_bassanetti/Media.java @@ -0,0 +1,28 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package b_bassanetti; + +/** + * + * @author alunno + */ +public class Media extends Trecce { + String tipoLegno; + String tipoFiocco; + + public Media(int codice, String nome, String forma, String colore, double costo, String tipoLegno, String tipoFiocco){ + super(codice, nome, forma, colore, costo); + this.tipoLegno = tipoLegno; + this.tipoFiocco = tipoFiocco; + } + + @Override + public String toString(){ + return super.toString() + + "\nTipo legno: " + this.tipoLegno + + "\nTipo fiocco: " + this.tipoFiocco; + } +} diff --git a/src/b_bassanetti/Piccola.java b/src/b_bassanetti/Piccola.java new file mode 100644 index 0000000..8f94383 --- /dev/null +++ b/src/b_bassanetti/Piccola.java @@ -0,0 +1,28 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package b_bassanetti; + +/** + * + * @author alunno + */ +public class Piccola extends Trecce { + String tipoCera; + String tipoFiore; + + public Piccola(int codice, String nome, String forma, String colore, double costo, String tipoCera, String tipoFiore){ + super(codice, nome, forma, colore, costo); + this.tipoCera = tipoCera; + this.tipoFiore = tipoFiore; + } + + @Override + public String toString(){ + return super.toString() + + "\nTipo cera: " + this.tipoCera + + "\nTipo fiore: " + this.tipoFiore; + } +} diff --git a/src/b_bassanetti/Trecce.java b/src/b_bassanetti/Trecce.java new file mode 100644 index 0000000..bc7684c --- /dev/null +++ b/src/b_bassanetti/Trecce.java @@ -0,0 +1,52 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package b_bassanetti; + +/** + * + * @author alunno + */ +public class Trecce { + + int codice; + String nome; + String forma; + String colore; + double costo; + + public Trecce(int codice, String nome, String forma, String colore, double costo) { + this.codice = codice; + this.nome = nome; + this.forma = forma; + this.colore = colore; + this.costo = costo; + } + + @Override + public String toString(){ + return "Codice: " + this.codice + + "\nNome: " + this.nome + + "\nForma: " + this.forma + + "\nColore: " + this.colore + + "\nCosto: " + this.costo ; + } + + public void aggiornaCosto(boolean direzione, double percentuale){ //true = aumenta + //false = decrementa + if(direzione){ + this.costo += (this.costo * percentuale) / 100; + }else{ + this.costo -= (this.costo * percentuale) / 100;} + } + + public String getColore() { + return colore; + } + + public double getCosto() { + return costo; + } +}