From e8566592178c12063a7d134c07c2add6cd19ec76 Mon Sep 17 00:00:00 2001 From: Giacomo Radaelli Date: Mon, 27 Mar 2023 18:43:31 +0200 Subject: [PATCH 1/2] Aggiunta prima versione di DataFormattata --- NetBeans Projects/Date/build.xml | 73 + .../Date/build/built-jar.properties | 4 + .../build/classes/.netbeans_automatic_build | 0 .../build/classes/.netbeans_update_resources | 0 NetBeans Projects/Date/manifest.mf | 3 + .../Date/nbproject/build-impl.xml | 1771 +++++++++++++++++ .../Date/nbproject/configs/JDK_20.properties | 2 + .../Date/nbproject/genfiles.properties | 8 + .../Date/nbproject/private/config.properties | 0 .../Date/nbproject/private/private.properties | 8 + .../Date/nbproject/private/private.xml | 13 + .../Date/nbproject/project.properties | 93 + NetBeans Projects/Date/nbproject/project.xml | 15 + .../Date/src/date/DataEstesa.java | 42 + .../Date/src/date/DataFormattata.java | 43 + .../Date/src/date/DataNumerica.java | 28 + .../Date/src/date/ProvaData.java | 22 + 17 files changed, 2125 insertions(+) create mode 100644 NetBeans Projects/Date/build.xml create mode 100644 NetBeans Projects/Date/build/built-jar.properties create mode 100644 NetBeans Projects/Date/build/classes/.netbeans_automatic_build create mode 100644 NetBeans Projects/Date/build/classes/.netbeans_update_resources create mode 100644 NetBeans Projects/Date/manifest.mf create mode 100644 NetBeans Projects/Date/nbproject/build-impl.xml create mode 100644 NetBeans Projects/Date/nbproject/configs/JDK_20.properties create mode 100644 NetBeans Projects/Date/nbproject/genfiles.properties create mode 100644 NetBeans Projects/Date/nbproject/private/config.properties create mode 100644 NetBeans Projects/Date/nbproject/private/private.properties create mode 100644 NetBeans Projects/Date/nbproject/private/private.xml create mode 100644 NetBeans Projects/Date/nbproject/project.properties create mode 100644 NetBeans Projects/Date/nbproject/project.xml create mode 100644 NetBeans Projects/Date/src/date/DataEstesa.java create mode 100644 NetBeans Projects/Date/src/date/DataFormattata.java create mode 100644 NetBeans Projects/Date/src/date/DataNumerica.java create mode 100644 NetBeans Projects/Date/src/date/ProvaData.java diff --git a/NetBeans Projects/Date/build.xml b/NetBeans Projects/Date/build.xml new file mode 100644 index 0000000..4395abe --- /dev/null +++ b/NetBeans Projects/Date/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project Date. + + + diff --git a/NetBeans Projects/Date/build/built-jar.properties b/NetBeans Projects/Date/build/built-jar.properties new file mode 100644 index 0000000..511436a --- /dev/null +++ b/NetBeans Projects/Date/build/built-jar.properties @@ -0,0 +1,4 @@ +#Mon, 27 Mar 2023 13:37:32 +0200 + + +/home/giacomo/NetBeansProjects/Date= diff --git a/NetBeans Projects/Date/build/classes/.netbeans_automatic_build b/NetBeans Projects/Date/build/classes/.netbeans_automatic_build new file mode 100644 index 0000000..e69de29 diff --git a/NetBeans Projects/Date/build/classes/.netbeans_update_resources b/NetBeans Projects/Date/build/classes/.netbeans_update_resources new file mode 100644 index 0000000..e69de29 diff --git a/NetBeans Projects/Date/manifest.mf b/NetBeans Projects/Date/manifest.mf new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/NetBeans Projects/Date/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/NetBeans Projects/Date/nbproject/build-impl.xml b/NetBeans Projects/Date/nbproject/build-impl.xml new file mode 100644 index 0000000..10521be --- /dev/null +++ b/NetBeans Projects/Date/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/NetBeans Projects/Date/nbproject/configs/JDK_20.properties b/NetBeans Projects/Date/nbproject/configs/JDK_20.properties new file mode 100644 index 0000000..310d92e --- /dev/null +++ b/NetBeans Projects/Date/nbproject/configs/JDK_20.properties @@ -0,0 +1,2 @@ +$label=JDK 20 +main.class=date.ProvaData diff --git a/NetBeans Projects/Date/nbproject/genfiles.properties b/NetBeans Projects/Date/nbproject/genfiles.properties new file mode 100644 index 0000000..ec53ad3 --- /dev/null +++ b/NetBeans Projects/Date/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=08068b56 +build.xml.script.CRC32=abd2dbd5 +build.xml.stylesheet.CRC32=f85dc8f2@1.106.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=08068b56 +nbproject/build-impl.xml.script.CRC32=f1e3a3c2 +nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.106.0.48 diff --git a/NetBeans Projects/Date/nbproject/private/config.properties b/NetBeans Projects/Date/nbproject/private/config.properties new file mode 100644 index 0000000..e69de29 diff --git a/NetBeans Projects/Date/nbproject/private/private.properties b/NetBeans Projects/Date/nbproject/private/private.properties new file mode 100644 index 0000000..a0ee013 --- /dev/null +++ b/NetBeans Projects/Date/nbproject/private/private.properties @@ -0,0 +1,8 @@ +compile.on.save=true +do.depend=false +do.jar=true +do.jlink=false +javac.debug=true +javadoc.preview=true +jlink.strip=false +user.properties.file=/home/giacomo/.netbeans/17/build.properties diff --git a/NetBeans Projects/Date/nbproject/private/private.xml b/NetBeans Projects/Date/nbproject/private/private.xml new file mode 100644 index 0000000..793f624 --- /dev/null +++ b/NetBeans Projects/Date/nbproject/private/private.xml @@ -0,0 +1,13 @@ + + + + + + file:/home/giacomo/NetBeansProjects/Date/src/date/DataEstesa.java + file:/home/giacomo/NetBeansProjects/Date/src/date/DataFormattata.java + file:/home/giacomo/NetBeansProjects/Date/src/date/DataNumerica.java + file:/home/giacomo/NetBeansProjects/Date/nbproject/project.properties + file:/home/giacomo/NetBeansProjects/Date/src/date/ProvaData.java + + + diff --git a/NetBeans Projects/Date/nbproject/project.properties b/NetBeans Projects/Date/nbproject/project.properties new file mode 100644 index 0000000..58d5328 --- /dev/null +++ b/NetBeans Projects/Date/nbproject/project.properties @@ -0,0 +1,93 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +application.title=Date +application.vendor=giacomo +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}/Date.jar +dist.javadoc.dir=${dist.dir}/javadoc +dist.jlink.dir=${dist.dir}/jlink +dist.jlink.output=${dist.jlink.dir}/Date +endorsed.classpath= +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=14 +javac.target=14 +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.html5=false +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +# The jlink additional root modules to resolve +jlink.additionalmodules= +# The jlink additional command line parameters +jlink.additionalparam= +jlink.launcher=true +jlink.launcher.name=Date +main.class=date.ProvaData +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} +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/NetBeans Projects/Date/nbproject/project.xml b/NetBeans Projects/Date/nbproject/project.xml new file mode 100644 index 0000000..0c76b34 --- /dev/null +++ b/NetBeans Projects/Date/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + Date + + + + + + + + + diff --git a/NetBeans Projects/Date/src/date/DataEstesa.java b/NetBeans Projects/Date/src/date/DataEstesa.java new file mode 100644 index 0000000..a10186d --- /dev/null +++ b/NetBeans Projects/Date/src/date/DataEstesa.java @@ -0,0 +1,42 @@ +package date; + +/** + * + * @author giacomo + */ +public class DataEstesa extends DataFormattata { + + public DataEstesa(int giorno, int mese, int anno) { + super(giorno, mese, anno); + } + + @Override + public String stringaFormattata() { + String data = ""; + + if(getGiorno() < 9) data += "0" + getGiorno(); + else data += getGiorno(); + + data += " "; + + switch (getMese()) { + case 1 -> data += "gennaio"; + case 2 -> data += "febbraio"; + case 3 -> data += "marzo"; + case 4 -> data += "aprile"; + case 5 -> data += "maggio"; + case 6 -> data += "giugno"; + case 7 -> data += "luglio"; + case 8 -> data += "agosto"; + case 9 -> data += "settembre"; + case 10 -> data += "ottobre"; + case 11 -> data += "novembre"; + case 12 -> data += "dicembre"; + } + + data += " " + getAnno(); + + return data; + } + +} diff --git a/NetBeans Projects/Date/src/date/DataFormattata.java b/NetBeans Projects/Date/src/date/DataFormattata.java new file mode 100644 index 0000000..aca100d --- /dev/null +++ b/NetBeans Projects/Date/src/date/DataFormattata.java @@ -0,0 +1,43 @@ +package date; + +/** + * + * @author giacomo + */ +public abstract class DataFormattata implements Comparable { + private int giorno; + private int mese; + private int anno; + + public DataFormattata(int giorno, int mese, int anno) { + if(giorno >= 1 && giorno <= 31) this.giorno = giorno; + else throw new IllegalArgumentException("Il numero del giorno non è valido"); + if(mese >= 1 && mese <= 12) this.mese = mese; + else throw new IllegalArgumentException("Il numero del mese non è valido"); + this.anno = anno; + } + + protected int getGiorno() { + return giorno; + } + + protected int getMese() { + return mese; + } + + protected int getAnno() { + return anno; + } + + @Override + public int compareTo(DataFormattata o) { + if(anno >= o.getAnno() && mese >= o.getMese() && giorno > o.getGiorno()) { + return 1; + } else if(anno == o.getAnno() && mese == o.getMese() && giorno == o.getGiorno()) { + return 0; + } else return -1; + } + + + public abstract String stringaFormattata(); +} diff --git a/NetBeans Projects/Date/src/date/DataNumerica.java b/NetBeans Projects/Date/src/date/DataNumerica.java new file mode 100644 index 0000000..20dd639 --- /dev/null +++ b/NetBeans Projects/Date/src/date/DataNumerica.java @@ -0,0 +1,28 @@ +package date; + +/** + * + * @author giacomo + */ +public class DataNumerica extends DataFormattata { + + public DataNumerica(int giorno, int mese, int anno) { + super(giorno, mese, anno); + } + + @Override + public String stringaFormattata() { + String giornoFormattato = ""; + String meseFormattato = ""; + //String annoFormattato = ""; + + if(getGiorno() < 9) giornoFormattato = "0" + getGiorno(); + else giornoFormattato += getGiorno(); + + if(getMese() < 9) meseFormattato = "0" + getMese(); + else meseFormattato += getMese(); + + return giornoFormattato + "/" + meseFormattato + "/" + getAnno(); + } + +} diff --git a/NetBeans Projects/Date/src/date/ProvaData.java b/NetBeans Projects/Date/src/date/ProvaData.java new file mode 100644 index 0000000..7b9b233 --- /dev/null +++ b/NetBeans Projects/Date/src/date/ProvaData.java @@ -0,0 +1,22 @@ +package date; + +import java.util.ArrayList; + +/** + * + * @author giacomo + */ +public class ProvaData { + public static void main(String[] args) { + ArrayList date = new ArrayList<>(); + + date.add(new DataNumerica(5, 7, 2020)); + date.add(new DataEstesa(5, 7, 2020)); + date.add(new DataEstesa(10, 7, 2020)); + + System.out.println(date.get(0).stringaFormattata()); + System.out.println(date.get(1).stringaFormattata()); + + System.out.println(date.get(2).compareTo(date.get(1))); + } +} From 3f17f672f2797758e6873d7316ee5bf3fd6b4df5 Mon Sep 17 00:00:00 2001 From: Giacomo Radaelli Date: Wed, 29 Mar 2023 20:18:16 +0200 Subject: [PATCH 2/2] Aggiornato Date con soluzione prof --- .../Date/src/date/DataEstesa.java | 2 +- .../Date/src/date/DataFormattata.java | 8 +++---- .../Date/src/date/DataNumerica.java | 22 ++++++++++++++----- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/NetBeans Projects/Date/src/date/DataEstesa.java b/NetBeans Projects/Date/src/date/DataEstesa.java index a10186d..0aa1341 100644 --- a/NetBeans Projects/Date/src/date/DataEstesa.java +++ b/NetBeans Projects/Date/src/date/DataEstesa.java @@ -14,7 +14,7 @@ public class DataEstesa extends DataFormattata { public String stringaFormattata() { String data = ""; - if(getGiorno() < 9) data += "0" + getGiorno(); + if(getGiorno() < 10) data += "0" + getGiorno(); else data += getGiorno(); data += " "; diff --git a/NetBeans Projects/Date/src/date/DataFormattata.java b/NetBeans Projects/Date/src/date/DataFormattata.java index aca100d..138ce78 100644 --- a/NetBeans Projects/Date/src/date/DataFormattata.java +++ b/NetBeans Projects/Date/src/date/DataFormattata.java @@ -31,11 +31,9 @@ public abstract class DataFormattata implements Comparable { @Override public int compareTo(DataFormattata o) { - if(anno >= o.getAnno() && mese >= o.getMese() && giorno > o.getGiorno()) { - return 1; - } else if(anno == o.getAnno() && mese == o.getMese() && giorno == o.getGiorno()) { - return 0; - } else return -1; + if(this.anno != o.anno) return this.anno - o.anno; + if(this.mese != o.mese) return this.mese - o.mese; + return this.giorno - o.giorno; } diff --git a/NetBeans Projects/Date/src/date/DataNumerica.java b/NetBeans Projects/Date/src/date/DataNumerica.java index 20dd639..8d6b000 100644 --- a/NetBeans Projects/Date/src/date/DataNumerica.java +++ b/NetBeans Projects/Date/src/date/DataNumerica.java @@ -12,17 +12,27 @@ public class DataNumerica extends DataFormattata { @Override public String stringaFormattata() { - String giornoFormattato = ""; + /*String giornoFormattato = ""; String meseFormattato = ""; - //String annoFormattato = ""; - if(getGiorno() < 9) giornoFormattato = "0" + getGiorno(); - else giornoFormattato += getGiorno(); + if(getGiorno() < 10) giornoFormattato = "0"; + giornoFormattato += getGiorno(); - if(getMese() < 9) meseFormattato = "0" + getMese(); - else meseFormattato += getMese(); + if(getMese() < 10) meseFormattato = "0"; + meseFormattato += getMese(); return giornoFormattato + "/" + meseFormattato + "/" + getAnno(); + */ + + int g = getGiorno(); + int m = getMese(); + int a = getAnno(); + + String res = (g<10) ? "0"+g : ""+g; + res += "/"; + res += (m<10) ? "0"+m : "" + m; + + return res + a; } }