From 472719c1665806c64390ccb83e792096d7efdb88 Mon Sep 17 00:00:00 2001 From: Giacomo Radaelli Date: Tue, 14 Feb 2023 18:09:32 +0100 Subject: [PATCH] Aggiunto LoginForm e Robot (IntelliJ) --- .gitignore | 3 + LoginForm/.idea/.gitignore | 3 + LoginForm/.idea/misc.xml | 6 + LoginForm/.idea/modules.xml | 8 + LoginForm/.idea/vcs.xml | 6 + LoginForm/LoginForm.iml | 11 + LoginForm/src/LoginForm.java | 28 + LoginForm/src/Main.java | 12 + NetBeans Projects/BankAccount/build.xml | 73 + NetBeans Projects/BankAccount/manifest.mf | 3 + .../BankAccount/nbproject/build-impl.xml | 1771 +++++++++++++++++ .../BankAccount/nbproject/genfiles.properties | 8 + .../BankAccount/nbproject/project.properties | 96 + .../BankAccount/nbproject/project.xml | 15 + .../BankAccount/src/BankAccount.java | 54 + Robot/.idea/.gitignore | 3 + Robot/.idea/misc.xml | 6 + Robot/.idea/modules.xml | 8 + Robot/.idea/vcs.xml | 6 + Robot/Robot.iml | 11 + Robot/src/Main.java | 17 + Robot/src/Robot.java | 45 + 22 files changed, 2193 insertions(+) create mode 100644 LoginForm/.idea/.gitignore create mode 100644 LoginForm/.idea/misc.xml create mode 100644 LoginForm/.idea/modules.xml create mode 100644 LoginForm/.idea/vcs.xml create mode 100644 LoginForm/LoginForm.iml create mode 100644 LoginForm/src/LoginForm.java create mode 100644 LoginForm/src/Main.java create mode 100644 NetBeans Projects/BankAccount/build.xml create mode 100644 NetBeans Projects/BankAccount/manifest.mf create mode 100644 NetBeans Projects/BankAccount/nbproject/build-impl.xml create mode 100644 NetBeans Projects/BankAccount/nbproject/genfiles.properties create mode 100644 NetBeans Projects/BankAccount/nbproject/project.properties create mode 100644 NetBeans Projects/BankAccount/nbproject/project.xml create mode 100644 NetBeans Projects/BankAccount/src/BankAccount.java create mode 100644 Robot/.idea/.gitignore create mode 100644 Robot/.idea/misc.xml create mode 100644 Robot/.idea/modules.xml create mode 100644 Robot/.idea/vcs.xml create mode 100644 Robot/Robot.iml create mode 100644 Robot/src/Main.java create mode 100644 Robot/src/Robot.java diff --git a/.gitignore b/.gitignore index afc9b0e..1229e6f 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,6 @@ hs_err_pid* /NetBeans Projects/esercizi/build/ /NetBeans Projects/LineaCalcoli/nbproject/private/ /NetBeans Projects/LineaCalcoli/build/ +/NetBeans Projects/BankAccount/nbproject/private/ +/NetBeans Projects/BankAccount/build/ +/NetBeans Projects/BankAccount/dist/ diff --git a/LoginForm/.idea/.gitignore b/LoginForm/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/LoginForm/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/LoginForm/.idea/misc.xml b/LoginForm/.idea/misc.xml new file mode 100644 index 0000000..7464918 --- /dev/null +++ b/LoginForm/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/LoginForm/.idea/modules.xml b/LoginForm/.idea/modules.xml new file mode 100644 index 0000000..6f5fb2b --- /dev/null +++ b/LoginForm/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/LoginForm/.idea/vcs.xml b/LoginForm/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/LoginForm/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/LoginForm/LoginForm.iml b/LoginForm/LoginForm.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/LoginForm/LoginForm.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/LoginForm/src/LoginForm.java b/LoginForm/src/LoginForm.java new file mode 100644 index 0000000..04bf2c8 --- /dev/null +++ b/LoginForm/src/LoginForm.java @@ -0,0 +1,28 @@ +public class LoginForm { + private String username; + private String password; + private int state; + + public LoginForm(String username, String password) { + this.username = username; + this.password = password; + state = 0; + } + + public void input(String text) { + if(state > 1) return; + if(state == 0 && username == text) state++; + if(state == 1 && password == text) state++; + } + + public void click(String button) { + if(state == 2) { + if(button == "Submit") state++; + if(button == "Reset") state = 0; + } + } + + public boolean loggedIn() { + return state == 3; + } +} diff --git a/LoginForm/src/Main.java b/LoginForm/src/Main.java new file mode 100644 index 0000000..62fcb83 --- /dev/null +++ b/LoginForm/src/Main.java @@ -0,0 +1,12 @@ +public class Main { + public static void main(String[] args) { + LoginForm login = new LoginForm("nametest", "pswtest"); + + login.input("nametest"); + login.input("pswtest"); + + login.click("Submit"); + + System.out.println("Accesso: " + login.loggedIn()); + } +} \ No newline at end of file diff --git a/NetBeans Projects/BankAccount/build.xml b/NetBeans Projects/BankAccount/build.xml new file mode 100644 index 0000000..b252f6f --- /dev/null +++ b/NetBeans Projects/BankAccount/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project BankAccount. + + + diff --git a/NetBeans Projects/BankAccount/manifest.mf b/NetBeans Projects/BankAccount/manifest.mf new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/NetBeans Projects/BankAccount/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/BankAccount/nbproject/build-impl.xml b/NetBeans Projects/BankAccount/nbproject/build-impl.xml new file mode 100644 index 0000000..7346bad --- /dev/null +++ b/NetBeans Projects/BankAccount/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/BankAccount/nbproject/genfiles.properties b/NetBeans Projects/BankAccount/nbproject/genfiles.properties new file mode 100644 index 0000000..c13e9e3 --- /dev/null +++ b/NetBeans Projects/BankAccount/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=7508f443 +build.xml.script.CRC32=97ae1b47 +build.xml.stylesheet.CRC32=f85dc8f2@1.105.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=7508f443 +nbproject/build-impl.xml.script.CRC32=bac915c7 +nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.105.0.48 diff --git a/NetBeans Projects/BankAccount/nbproject/project.properties b/NetBeans Projects/BankAccount/nbproject/project.properties new file mode 100644 index 0000000..7010b2a --- /dev/null +++ b/NetBeans Projects/BankAccount/nbproject/project.properties @@ -0,0 +1,96 @@ +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}/BankAccount.jar +dist.javadoc.dir=${dist.dir}/javadoc +dist.jlink.dir=${dist.dir}/jlink +dist.jlink.output=${dist.jlink.dir}/BankAccount +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=11 +javac.target=11 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir}:\ + ${libs.junit_5.classpath} +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=BankAccount +main.class= +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/NetBeans Projects/BankAccount/nbproject/project.xml b/NetBeans Projects/BankAccount/nbproject/project.xml new file mode 100644 index 0000000..950c553 --- /dev/null +++ b/NetBeans Projects/BankAccount/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + BankAccount + + + + + + + + + diff --git a/NetBeans Projects/BankAccount/src/BankAccount.java b/NetBeans Projects/BankAccount/src/BankAccount.java new file mode 100644 index 0000000..a68ed6e --- /dev/null +++ b/NetBeans Projects/BankAccount/src/BankAccount.java @@ -0,0 +1,54 @@ +import java.util.ArrayList; + +public class BankAccount { + private double balance; + private ArrayList movements; + + //*** INIZIO METODI FORNITI DAL LIBRO *** + /** + Constructs a bank account with a zero balance. + */ + public BankAccount() { + balance = 0; + movements = new ArrayList<>(); + } + + /** + Deposits money into the bank account. + @param amount the amount to deposit + */ + public void deposit(double amount) { + movements.add(amount); + balance = balance + amount; + } + + /** + Withdraws money from the bank account. + @param amount the amount to withdraw + */ + public void withdraw(double amount) + { + movements.add(-amount); + balance = balance - amount; + } + + /** + Gets the current balance of the bank account. + @return the current balance + */ + public double getBalance() { + return balance; + } + + //*** FINE METODI FORNITI DAL LIBRO *** + + public ArrayList getStatement() { + return movements; + } + + public void clearStatement() { + movements.clear(); + } +} + + diff --git a/Robot/.idea/.gitignore b/Robot/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/Robot/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/Robot/.idea/misc.xml b/Robot/.idea/misc.xml new file mode 100644 index 0000000..03f397c --- /dev/null +++ b/Robot/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Robot/.idea/modules.xml b/Robot/.idea/modules.xml new file mode 100644 index 0000000..4d12aae --- /dev/null +++ b/Robot/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Robot/.idea/vcs.xml b/Robot/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/Robot/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Robot/Robot.iml b/Robot/Robot.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/Robot/Robot.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Robot/src/Main.java b/Robot/src/Main.java new file mode 100644 index 0000000..cb197b8 --- /dev/null +++ b/Robot/src/Main.java @@ -0,0 +1,17 @@ +public class Main { + public static void main(String[] args) { + Robot test = new Robot(); + + test.turnRight(); + test.move(); + test.move(); + test.move(); + test.move(); + test.turnRight(); + test.move(); + test.move(); + test.move(); + + System.out.println(test.getDirection()); + } +} \ No newline at end of file diff --git a/Robot/src/Robot.java b/Robot/src/Robot.java new file mode 100644 index 0000000..47710a0 --- /dev/null +++ b/Robot/src/Robot.java @@ -0,0 +1,45 @@ +import java.awt.Point; + +/** + * State = 0 -> verso su + * State = 1 -> verso destra + * State = 2 -> verso il basso + * State = 3 -> verso sinistra + */ +public class Robot { + private int state; + private Point pos; + + public Robot() { + state = 0; + pos = new Point(); + } + + public void turnLeft() { + if(state == 0) state = 3; + else state--; + } + + public void turnRight() { + if(state == 3) state = 0; + else state++; + } + + public void move() { + if(state == 0) pos.translate(0, 1); + else if(state == 1) pos.translate(1, 0); + else if(state == 2) pos.translate(0, -1); + else pos.translate(-1, 0); + } + + public Point getLocation() { + return pos; + } + + public String getDirection() { + if(state == 0) return "N"; + else if(state == 1) return "E"; + else if(state == 2) return "S"; + else return "W"; + } +}