Aggiunta grafica e ricorsione
This commit is contained in:
parent
2bfc3a410c
commit
76aa0080c6
|
@ -36,3 +36,5 @@ hs_err_pid*
|
||||||
/NetBeans Projects/BankAccount/dist/
|
/NetBeans Projects/BankAccount/dist/
|
||||||
/NetBeans Projects/Inventory/build/
|
/NetBeans Projects/Inventory/build/
|
||||||
/NetBeans Projects/Grafica/nbproject/private/
|
/NetBeans Projects/Grafica/nbproject/private/
|
||||||
|
/NetBeans Projects/Ricorsione/nbproject/private/
|
||||||
|
/NetBeans Projects/Ricorsione/build/
|
||||||
|
|
|
@ -1,73 +1,73 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!-- You may freely edit this file. See commented blocks below for -->
|
<!-- You may freely edit this file. See commented blocks below for -->
|
||||||
<!-- some examples of how to customize the build. -->
|
<!-- some examples of how to customize the build. -->
|
||||||
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
||||||
<!-- By default, only the Clean and Build commands use this build script. -->
|
<!-- By default, only the Clean and Build commands use this build script. -->
|
||||||
<!-- Commands such as Run, Debug, and Test only use this build script if -->
|
<!-- Commands such as Run, Debug, and Test only use this build script if -->
|
||||||
<!-- the Compile on Save feature is turned off for the project. -->
|
<!-- the Compile on Save feature is turned off for the project. -->
|
||||||
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
||||||
<!-- in the project's Project Properties dialog box.-->
|
<!-- in the project's Project Properties dialog box.-->
|
||||||
<project name="Grafica" default="default" basedir=".">
|
<project name="Grafica" default="default" basedir=".">
|
||||||
<description>Builds, tests, and runs the project Grafica.</description>
|
<description>Builds, tests, and runs the project Grafica.</description>
|
||||||
<import file="nbproject/build-impl.xml"/>
|
<import file="nbproject/build-impl.xml"/>
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
There exist several targets which are by default empty and which can be
|
There exist several targets which are by default empty and which can be
|
||||||
used for execution of your tasks. These targets are usually executed
|
used for execution of your tasks. These targets are usually executed
|
||||||
before and after some main targets. They are:
|
before and after some main targets. They are:
|
||||||
|
|
||||||
-pre-init: called before initialization of project properties
|
-pre-init: called before initialization of project properties
|
||||||
-post-init: called after initialization of project properties
|
-post-init: called after initialization of project properties
|
||||||
-pre-compile: called before javac compilation
|
-pre-compile: called before javac compilation
|
||||||
-post-compile: called after javac compilation
|
-post-compile: called after javac compilation
|
||||||
-pre-compile-single: called before javac compilation of single file
|
-pre-compile-single: called before javac compilation of single file
|
||||||
-post-compile-single: called after javac compilation of single file
|
-post-compile-single: called after javac compilation of single file
|
||||||
-pre-compile-test: called before javac compilation of JUnit tests
|
-pre-compile-test: called before javac compilation of JUnit tests
|
||||||
-post-compile-test: called after javac compilation of JUnit tests
|
-post-compile-test: called after javac compilation of JUnit tests
|
||||||
-pre-compile-test-single: called before javac compilation of single JUnit test
|
-pre-compile-test-single: called before javac compilation of single JUnit test
|
||||||
-post-compile-test-single: called after javac compilation of single JUunit test
|
-post-compile-test-single: called after javac compilation of single JUunit test
|
||||||
-pre-jar: called before JAR building
|
-pre-jar: called before JAR building
|
||||||
-post-jar: called after JAR building
|
-post-jar: called after JAR building
|
||||||
-post-clean: called after cleaning build products
|
-post-clean: called after cleaning build products
|
||||||
|
|
||||||
(Targets beginning with '-' are not intended to be called on their own.)
|
(Targets beginning with '-' are not intended to be called on their own.)
|
||||||
|
|
||||||
Example of inserting an obfuscator after compilation could look like this:
|
Example of inserting an obfuscator after compilation could look like this:
|
||||||
|
|
||||||
<target name="-post-compile">
|
<target name="-post-compile">
|
||||||
<obfuscate>
|
<obfuscate>
|
||||||
<fileset dir="${build.classes.dir}"/>
|
<fileset dir="${build.classes.dir}"/>
|
||||||
</obfuscate>
|
</obfuscate>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
For list of available properties check the imported
|
For list of available properties check the imported
|
||||||
nbproject/build-impl.xml file.
|
nbproject/build-impl.xml file.
|
||||||
|
|
||||||
|
|
||||||
Another way to customize the build is by overriding existing main targets.
|
Another way to customize the build is by overriding existing main targets.
|
||||||
The targets of interest are:
|
The targets of interest are:
|
||||||
|
|
||||||
-init-macrodef-javac: defines macro for javac compilation
|
-init-macrodef-javac: defines macro for javac compilation
|
||||||
-init-macrodef-junit: defines macro for junit execution
|
-init-macrodef-junit: defines macro for junit execution
|
||||||
-init-macrodef-debug: defines macro for class debugging
|
-init-macrodef-debug: defines macro for class debugging
|
||||||
-init-macrodef-java: defines macro for class execution
|
-init-macrodef-java: defines macro for class execution
|
||||||
-do-jar: JAR building
|
-do-jar: JAR building
|
||||||
run: execution of project
|
run: execution of project
|
||||||
-javadoc-build: Javadoc generation
|
-javadoc-build: Javadoc generation
|
||||||
test-report: JUnit report generation
|
test-report: JUnit report generation
|
||||||
|
|
||||||
An example of overriding the target for project execution could look like this:
|
An example of overriding the target for project execution could look like this:
|
||||||
|
|
||||||
<target name="run" depends="Grafica-impl.jar">
|
<target name="run" depends="Grafica-impl.jar">
|
||||||
<exec dir="bin" executable="launcher.exe">
|
<exec dir="bin" executable="launcher.exe">
|
||||||
<arg file="${dist.jar}"/>
|
<arg file="${dist.jar}"/>
|
||||||
</exec>
|
</exec>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
Notice that the overridden target depends on the jar target and not only on
|
Notice that the overridden target depends on the jar target and not only on
|
||||||
the compile target as the regular run target does. Again, for a list of available
|
the compile target as the regular run target does. Again, for a list of available
|
||||||
properties which you can use, check the target you are overriding in the
|
properties which you can use, check the target you are overriding in the
|
||||||
nbproject/build-impl.xml file.
|
nbproject/build-impl.xml file.
|
||||||
|
|
||||||
-->
|
-->
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
#Mon, 22 May 2023 12:35:23 +0200
|
||||||
|
|
||||||
|
|
||||||
|
Z\:\\Informatica\\Java\\NetBeans\\Grafica=
|
|
@ -1,3 +1,3 @@
|
||||||
Manifest-Version: 1.0
|
Manifest-Version: 1.0
|
||||||
X-COMMENT: Main-Class will be added automatically by build
|
X-COMMENT: Main-Class will be added automatically by build
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,8 +1,8 @@
|
||||||
build.xml.data.CRC32=acf20e45
|
build.xml.data.CRC32=7a406286
|
||||||
build.xml.script.CRC32=761ebeaf
|
build.xml.script.CRC32=761ebeaf
|
||||||
build.xml.stylesheet.CRC32=f85dc8f2@1.106.0.48
|
build.xml.stylesheet.CRC32=f85dc8f2@1.99.0.48
|
||||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
# 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.
|
# 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=acf20e45
|
nbproject/build-impl.xml.data.CRC32=7a406286
|
||||||
nbproject/build-impl.xml.script.CRC32=a1851d6a
|
nbproject/build-impl.xml.script.CRC32=c26710d0
|
||||||
nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.106.0.48
|
nbproject/build-impl.xml.stylesheet.CRC32=d549e5cc@1.99.0.48
|
||||||
|
|
|
@ -1,95 +1,97 @@
|
||||||
annotation.processing.enabled=true
|
annotation.processing.enabled=true
|
||||||
annotation.processing.enabled.in.editor=false
|
annotation.processing.enabled.in.editor=false
|
||||||
annotation.processing.processor.options=
|
annotation.processing.processors.list=
|
||||||
annotation.processing.processors.list=
|
annotation.processing.run.all.processors=true
|
||||||
annotation.processing.run.all.processors=true
|
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
||||||
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
application.title=Grafica
|
||||||
build.classes.dir=${build.dir}/classes
|
application.vendor=radaelli11353
|
||||||
build.classes.excludes=**/*.java,**/*.form
|
build.classes.dir=${build.dir}/classes
|
||||||
# This directory is removed when the project is cleaned:
|
build.classes.excludes=**/*.java,**/*.form
|
||||||
build.dir=build
|
# This directory is removed when the project is cleaned:
|
||||||
build.generated.dir=${build.dir}/generated
|
build.dir=build
|
||||||
build.generated.sources.dir=${build.dir}/generated-sources
|
build.generated.dir=${build.dir}/generated
|
||||||
# Only compile against the classpath explicitly listed here:
|
build.generated.sources.dir=${build.dir}/generated-sources
|
||||||
build.sysclasspath=ignore
|
# Only compile against the classpath explicitly listed here:
|
||||||
build.test.classes.dir=${build.dir}/test/classes
|
build.sysclasspath=ignore
|
||||||
build.test.results.dir=${build.dir}/test/results
|
build.test.classes.dir=${build.dir}/test/classes
|
||||||
# Uncomment to specify the preferred debugger connection transport:
|
build.test.results.dir=${build.dir}/test/results
|
||||||
#debug.transport=dt_socket
|
# Uncomment to specify the preferred debugger connection transport:
|
||||||
debug.classpath=\
|
#debug.transport=dt_socket
|
||||||
${run.classpath}
|
debug.classpath=\
|
||||||
debug.modulepath=\
|
${run.classpath}
|
||||||
${run.modulepath}
|
debug.modulepath=\
|
||||||
debug.test.classpath=\
|
${run.modulepath}
|
||||||
${run.test.classpath}
|
debug.test.classpath=\
|
||||||
debug.test.modulepath=\
|
${run.test.classpath}
|
||||||
${run.test.modulepath}
|
debug.test.modulepath=\
|
||||||
# Files in build.classes.dir which should be excluded from distribution jar
|
${run.test.modulepath}
|
||||||
dist.archive.excludes=
|
# Files in build.classes.dir which should be excluded from distribution jar
|
||||||
# This directory is removed when the project is cleaned:
|
dist.archive.excludes=
|
||||||
dist.dir=dist
|
# This directory is removed when the project is cleaned:
|
||||||
dist.jar=${dist.dir}/Grafica.jar
|
dist.dir=dist
|
||||||
dist.javadoc.dir=${dist.dir}/javadoc
|
dist.jar=${dist.dir}/Grafica.jar
|
||||||
dist.jlink.dir=${dist.dir}/jlink
|
dist.javadoc.dir=${dist.dir}/javadoc
|
||||||
dist.jlink.output=${dist.jlink.dir}/Grafica
|
dist.jlink.dir=${dist.dir}/jlink
|
||||||
excludes=
|
dist.jlink.output=${dist.jlink.dir}/Grafica
|
||||||
includes=**
|
endorsed.classpath=
|
||||||
jar.compress=false
|
excludes=
|
||||||
javac.classpath=
|
includes=**
|
||||||
# Space-separated list of extra javac options
|
jar.compress=false
|
||||||
javac.compilerargs=
|
javac.classpath=
|
||||||
javac.deprecation=false
|
# Space-separated list of extra javac options
|
||||||
javac.external.vm=true
|
javac.compilerargs=
|
||||||
javac.modulepath=
|
javac.deprecation=false
|
||||||
javac.processormodulepath=
|
javac.external.vm=true
|
||||||
javac.processorpath=\
|
javac.modulepath=
|
||||||
${javac.classpath}
|
javac.processormodulepath=
|
||||||
javac.source=17
|
javac.processorpath=\
|
||||||
javac.target=17
|
${javac.classpath}
|
||||||
javac.test.classpath=\
|
javac.source=16
|
||||||
${javac.classpath}:\
|
javac.target=16
|
||||||
${build.classes.dir}
|
javac.test.classpath=\
|
||||||
javac.test.modulepath=\
|
${javac.classpath}:\
|
||||||
${javac.modulepath}
|
${build.classes.dir}
|
||||||
javac.test.processorpath=\
|
javac.test.modulepath=\
|
||||||
${javac.test.classpath}
|
${javac.modulepath}
|
||||||
javadoc.additionalparam=
|
javac.test.processorpath=\
|
||||||
javadoc.author=false
|
${javac.test.classpath}
|
||||||
javadoc.encoding=${source.encoding}
|
javadoc.additionalparam=
|
||||||
javadoc.html5=false
|
javadoc.author=false
|
||||||
javadoc.noindex=false
|
javadoc.encoding=${source.encoding}
|
||||||
javadoc.nonavbar=false
|
javadoc.html5=false
|
||||||
javadoc.notree=false
|
javadoc.noindex=false
|
||||||
javadoc.private=false
|
javadoc.nonavbar=false
|
||||||
javadoc.splitindex=true
|
javadoc.notree=false
|
||||||
javadoc.use=true
|
javadoc.private=false
|
||||||
javadoc.version=false
|
javadoc.splitindex=true
|
||||||
javadoc.windowtitle=
|
javadoc.use=true
|
||||||
# The jlink additional root modules to resolve
|
javadoc.version=false
|
||||||
jlink.additionalmodules=
|
javadoc.windowtitle=
|
||||||
# The jlink additional command line parameters
|
# The jlink additional root modules to resolve
|
||||||
jlink.additionalparam=
|
jlink.additionalmodules=
|
||||||
jlink.launcher=true
|
# The jlink additional command line parameters
|
||||||
jlink.launcher.name=Grafica
|
jlink.additionalparam=
|
||||||
main.class=shape.ShapesViewer
|
jlink.launcher=true
|
||||||
manifest.file=manifest.mf
|
jlink.launcher.name=Grafica
|
||||||
meta.inf.dir=${src.dir}/META-INF
|
main.class=shape.ShapesViewer
|
||||||
mkdist.disabled=false
|
manifest.file=manifest.mf
|
||||||
platform.active=Zulu_17.0.6_10
|
meta.inf.dir=${src.dir}/META-INF
|
||||||
run.classpath=\
|
mkdist.disabled=false
|
||||||
${javac.classpath}:\
|
platform.active=default_platform
|
||||||
${build.classes.dir}
|
run.classpath=\
|
||||||
# Space-separated list of JVM arguments used when running the project.
|
${javac.classpath}:\
|
||||||
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
|
${build.classes.dir}
|
||||||
# To set system properties for unit tests define test-sys-prop.name=value:
|
# Space-separated list of JVM arguments used when running the project.
|
||||||
run.jvmargs=
|
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
|
||||||
run.modulepath=\
|
# To set system properties for unit tests define test-sys-prop.name=value:
|
||||||
${javac.modulepath}
|
run.jvmargs=
|
||||||
run.test.classpath=\
|
run.modulepath=\
|
||||||
${javac.test.classpath}:\
|
${javac.modulepath}
|
||||||
${build.test.classes.dir}
|
run.test.classpath=\
|
||||||
run.test.modulepath=\
|
${javac.test.classpath}:\
|
||||||
${javac.test.modulepath}
|
${build.test.classes.dir}
|
||||||
source.encoding=UTF-8
|
run.test.modulepath=\
|
||||||
src.dir=src
|
${javac.test.modulepath}
|
||||||
test.src.dir=test
|
source.encoding=UTF-8
|
||||||
|
src.dir=src
|
||||||
|
test.src.dir=test
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://www.netbeans.org/ns/project/1">
|
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||||
<type>org.netbeans.modules.java.j2seproject</type>
|
<type>org.netbeans.modules.java.j2seproject</type>
|
||||||
<configuration>
|
<configuration>
|
||||||
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
||||||
<name>Grafica</name>
|
<name>Grafica</name>
|
||||||
<explicit-platform explicit-source-supported="true"/>
|
<source-roots>
|
||||||
<source-roots>
|
<root id="src.dir"/>
|
||||||
<root id="src.dir"/>
|
</source-roots>
|
||||||
</source-roots>
|
<test-roots>
|
||||||
<test-roots>
|
<root id="test.src.dir"/>
|
||||||
<root id="test.src.dir"/>
|
</test-roots>
|
||||||
</test-roots>
|
</data>
|
||||||
</data>
|
</configuration>
|
||||||
</configuration>
|
</project>
|
||||||
</project>
|
|
||||||
|
|
|
@ -1,28 +1,28 @@
|
||||||
package investment;
|
package investment;
|
||||||
|
|
||||||
public class BankAccount {
|
public class BankAccount {
|
||||||
private double balance;
|
private double balance;
|
||||||
|
|
||||||
public BankAccount() {
|
public BankAccount() {
|
||||||
balance = 0;
|
balance = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BankAccount(double initialBalance) {
|
public BankAccount(double initialBalance) {
|
||||||
balance = initialBalance;
|
balance = initialBalance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deposit(double amount) {
|
public void deposit(double amount) {
|
||||||
double newBalance = balance + amount;
|
double newBalance = balance + amount;
|
||||||
balance = newBalance;
|
balance = newBalance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void withdraw(double amount) {
|
public void withdraw(double amount) {
|
||||||
double newBalance = balance - amount;
|
double newBalance = balance - amount;
|
||||||
balance = newBalance;
|
balance = newBalance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getBalance() {
|
public double getBalance() {
|
||||||
return balance;
|
return balance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
* 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 investment;
|
||||||
|
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author radaelli11353
|
||||||
|
*/
|
||||||
|
class InterestListener1 implements ActionListener {
|
||||||
|
private static final double INITIAL_BALANCE = 1000;
|
||||||
|
private final BankAccount account;
|
||||||
|
private final double INTEREST_RATE;
|
||||||
|
|
||||||
|
public InterestListener1(double interest) {
|
||||||
|
account = new BankAccount(INITIAL_BALANCE);
|
||||||
|
INTEREST_RATE = interest;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent event) {
|
||||||
|
double interest = account.getBalance() * INTEREST_RATE / 100;
|
||||||
|
account.deposit(interest);
|
||||||
|
System.out.println("saldo: " + account.getBalance());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* 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 investment;
|
||||||
|
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author radaelli11353
|
||||||
|
*/
|
||||||
|
class InterestListener2 implements ActionListener {
|
||||||
|
private static final double INITIAL_BALANCE = 1000;
|
||||||
|
private BankAccount account;
|
||||||
|
private final double INTEREST_RATE;
|
||||||
|
private final JLabel label;
|
||||||
|
|
||||||
|
public InterestListener2(double interest, JLabel label) {
|
||||||
|
account = new BankAccount(INITIAL_BALANCE);
|
||||||
|
INTEREST_RATE = interest;
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent event) {
|
||||||
|
double interest = account.getBalance() * INTEREST_RATE / 100;
|
||||||
|
account.deposit(interest);
|
||||||
|
label.setText("Saldo: " + account.getBalance());
|
||||||
|
System.out.println(label.getText());
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,39 +1,28 @@
|
||||||
package investment;
|
package investment;
|
||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.ActionListener;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JFrame;
|
|
||||||
|
public class InvestmentViewer1 {
|
||||||
public class InvestmentViewer1 {
|
private static final int FRAME_WIDTH = 120;
|
||||||
private static final int FRAME_WIDTH = 120;
|
private static final int FRAME_HEIGHT = 60;
|
||||||
private static final int FRAME_HEIGHT = 60;
|
|
||||||
|
private static final double INTEREST_RATE = 10;
|
||||||
private static final double INTEREST_RATE = 10;
|
private static final double INITIAL_BALANCE = 1000;
|
||||||
private static final double INITIAL_BALANCE = 1000;
|
|
||||||
|
public static void main(String[] args) {
|
||||||
public static void main(String[] args) {
|
JFrame frame = new JFrame();
|
||||||
JFrame frame = new JFrame();
|
frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
|
||||||
frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
||||||
|
JButton button = new JButton("Aggiungi interessi");
|
||||||
BankAccount account = new BankAccount(INITIAL_BALANCE);
|
frame.add(button);
|
||||||
|
|
||||||
JButton button = new JButton("Aggiungi interessi");
|
ActionListener listener = new InterestListener1(INTEREST_RATE);
|
||||||
frame.add(button);
|
button.addActionListener(listener);
|
||||||
|
|
||||||
class InterestListener implements ActionListener {
|
frame.setVisible(true);
|
||||||
public void actionPerformed(ActionEvent event) {
|
}
|
||||||
double interest = account.getBalance() * INTEREST_RATE / 100;
|
}
|
||||||
account.deposit(interest);
|
|
||||||
System.out.println("saldo: " + account.getBalance());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ActionListener listener = new InterestListener();
|
|
||||||
button.addActionListener(listener);
|
|
||||||
|
|
||||||
frame.setVisible(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package investment;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
|
public class InvestmentViewer1Lambda {
|
||||||
|
private static final int FRAME_WIDTH = 120;
|
||||||
|
private static final int FRAME_HEIGHT = 60;
|
||||||
|
|
||||||
|
private static final double INTEREST_RATE = 10;
|
||||||
|
private static final double INITIAL_BALANCE = 1000;
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
JFrame frame = new JFrame();
|
||||||
|
frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
|
||||||
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
|
||||||
|
BankAccount account = new BankAccount(INITIAL_BALANCE);
|
||||||
|
|
||||||
|
JButton button = new JButton("Aggiungi interessi");
|
||||||
|
frame.add(button);
|
||||||
|
|
||||||
|
button.addActionListener(event -> {
|
||||||
|
double interest = account.getBalance() * INTEREST_RATE / 100;
|
||||||
|
account.deposit(interest);
|
||||||
|
System.out.println("Saldo: " + account.getBalance());
|
||||||
|
});
|
||||||
|
|
||||||
|
frame.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,46 +1,38 @@
|
||||||
package investment;
|
package investment;
|
||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.ActionListener;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JPanel;
|
|
||||||
|
public class InvestmentViewer2 {
|
||||||
public class InvestmentViewer2 {
|
private static final int FRAME_WIDTH = 400;
|
||||||
private static final int FRAME_WIDTH = 400;
|
private static final int FRAME_HEIGHT = 100;
|
||||||
private static final int FRAME_HEIGHT = 100;
|
|
||||||
|
private static final double INTEREST_RATE = 10;
|
||||||
private static final double INTEREST_RATE = 10;
|
private static final double INITIAL_BALANCE = 1000;
|
||||||
private static final double INITIAL_BALANCE = 1000;
|
|
||||||
|
public static void main(String[] args) {
|
||||||
public static void main(String[] args) {
|
JFrame frame = new JFrame();
|
||||||
JFrame frame = new JFrame();
|
frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
|
||||||
frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
||||||
|
BankAccount account = new BankAccount(INITIAL_BALANCE);
|
||||||
BankAccount account = new BankAccount(INITIAL_BALANCE);
|
|
||||||
|
JButton button = new JButton("Aggiungi interessi");
|
||||||
JButton button = new JButton("Aggiungi interessi");
|
JLabel label = new JLabel("Saldo: " + account.getBalance());
|
||||||
JLabel label = new JLabel("Saldo: " + account.getBalance());
|
JPanel panel = new JPanel();
|
||||||
JPanel panel = new JPanel();
|
|
||||||
|
panel.add(button);
|
||||||
panel.add(button);
|
panel.add(label);
|
||||||
panel.add(label);
|
frame.add(panel);
|
||||||
frame.add(panel);
|
|
||||||
|
|
||||||
class InterestListener implements ActionListener {
|
ActionListener listener = new InterestListener2(INTEREST_RATE, label);
|
||||||
public void actionPerformed(ActionEvent event) {
|
button.addActionListener(listener);
|
||||||
double interest = account.getBalance() * INTEREST_RATE / 100;
|
|
||||||
account.deposit(interest);
|
frame.setVisible(true);
|
||||||
label.setText("Saldo: " + account.getBalance());
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ActionListener listener = new InterestListener();
|
|
||||||
button.addActionListener(listener);
|
|
||||||
|
|
||||||
frame.setVisible(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
package investment;
|
||||||
|
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
public class InvestmentViewer2Lambda {
|
||||||
|
private static final int FRAME_WIDTH = 400;
|
||||||
|
private static final int FRAME_HEIGHT = 100;
|
||||||
|
|
||||||
|
private static final double INTEREST_RATE = 10;
|
||||||
|
private static final double INITIAL_BALANCE = 1000;
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
JFrame frame = new JFrame();
|
||||||
|
frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
|
||||||
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
|
||||||
|
BankAccount account = new BankAccount(INITIAL_BALANCE);
|
||||||
|
|
||||||
|
JButton button = new JButton("Aggiungi interessi");
|
||||||
|
JLabel label = new JLabel("Saldo: " + account.getBalance());
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
|
||||||
|
panel.add(button);
|
||||||
|
panel.add(label);
|
||||||
|
frame.add(panel);
|
||||||
|
|
||||||
|
|
||||||
|
ActionListener listener = new InterestListener2(INTEREST_RATE, label);
|
||||||
|
button.addActionListener(event -> {
|
||||||
|
double interest = account.getBalance() * INTEREST_RATE / 100;
|
||||||
|
account.deposit(interest);
|
||||||
|
label.setText("Saldo: " + account.getBalance());
|
||||||
|
System.out.println(label.getText());
|
||||||
|
});
|
||||||
|
|
||||||
|
frame.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,53 +1,53 @@
|
||||||
package shape;
|
package shape;
|
||||||
|
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.geom.Ellipse2D;
|
import java.awt.geom.Ellipse2D;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author radaelli11353
|
* @author radaelli11353
|
||||||
*/
|
*/
|
||||||
public class Circle extends Shape {
|
public class Circle extends Shape {
|
||||||
private double r;
|
private double r;
|
||||||
|
|
||||||
public Circle(double xc, double yc, double r) {
|
public Circle(double xc, double yc, double r) {
|
||||||
super(xc-r, yc-r);
|
super(xc-r, yc-r);
|
||||||
this.r = r;
|
this.r = r;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRadius(double r) {
|
public void setRadius(double r) {
|
||||||
this.r = r;
|
this.r = r;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double width() {
|
public double width() {
|
||||||
return r*2;
|
return r*2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double height() {
|
public double height() {
|
||||||
return r*2;
|
return r*2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int hash = 5;
|
int hash = 5;
|
||||||
hash = 83 * hash + (int) (Double.doubleToLongBits(this.r) ^ (Double.doubleToLongBits(this.r) >>> 32));
|
hash = 83 * hash + (int) (Double.doubleToLongBits(this.r) ^ (Double.doubleToLongBits(this.r) >>> 32));
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (o == null) return false;
|
if (o == null) return false;
|
||||||
if (getClass() != o.getClass()) return false;
|
if (getClass() != o.getClass()) return false;
|
||||||
Circle c = (Circle) o;
|
Circle c = (Circle) o;
|
||||||
return r == c.r;
|
return r == c.r;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2) {
|
public void draw(Graphics2D g2) {
|
||||||
Ellipse2D.Double e = new Ellipse2D.Double(posX(), posY(), width(), height());
|
Ellipse2D.Double e = new Ellipse2D.Double(posX(), posY(), width(), height());
|
||||||
|
|
||||||
g2.draw(e);
|
g2.draw(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,47 +1,47 @@
|
||||||
package shape;
|
package shape;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
|
|
||||||
public class Geometria {
|
public class Geometria {
|
||||||
private ArrayList<Shape> elementi;
|
private ArrayList<Shape> elementi;
|
||||||
|
|
||||||
public Geometria() {
|
public Geometria() {
|
||||||
elementi = new ArrayList<>();
|
elementi = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void riempiACaso(int size) {
|
public void riempiACaso(int size) {
|
||||||
Random r = new Random();
|
Random r = new Random();
|
||||||
|
|
||||||
for(int i = 0; i < size; i++) {
|
for(int i = 0; i < size; i++) {
|
||||||
int s = r.nextInt(3);
|
int s = r.nextInt(3);
|
||||||
|
|
||||||
double x = r.nextDouble()*300;
|
double x = r.nextDouble()*300;
|
||||||
double y = r.nextDouble()*300;
|
double y = r.nextDouble()*300;
|
||||||
|
|
||||||
switch(s) {
|
switch(s) {
|
||||||
case 0:
|
case 0:
|
||||||
//circle
|
//circle
|
||||||
double raggio = r.nextDouble()*30;
|
double raggio = r.nextDouble()*30;
|
||||||
elementi.add(new Circle(x, y, raggio));
|
elementi.add(new Circle(x, y, raggio));
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
//square
|
//square
|
||||||
double lato = r.nextDouble()*40;
|
double lato = r.nextDouble()*40;
|
||||||
elementi.add(new Square(x, y, lato));
|
elementi.add(new Square(x, y, lato));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
//triangolo
|
//triangolo
|
||||||
double base = r.nextDouble()*30;
|
double base = r.nextDouble()*30;
|
||||||
double altezza = r.nextDouble()*30;
|
double altezza = r.nextDouble()*30;
|
||||||
elementi.add(new TriangoloRettangolo(x, y, base, altezza));
|
elementi.add(new TriangoloRettangolo(x, y, base, altezza));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void draw(Graphics2D g2) {
|
public void draw(Graphics2D g2) {
|
||||||
for(Shape s : elementi) s.draw(g2);
|
for(Shape s : elementi) s.draw(g2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,32 +1,32 @@
|
||||||
package shape;
|
package shape;
|
||||||
|
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author radaelli11353
|
* @author radaelli11353
|
||||||
*/
|
*/
|
||||||
public abstract class Shape implements Comparable<Shape> {
|
public abstract class Shape implements Comparable<Shape> {
|
||||||
private double x, y;
|
private double x, y;
|
||||||
|
|
||||||
public Shape(double x, double y) {
|
public Shape(double x, double y) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract double width();
|
public abstract double width();
|
||||||
public abstract double height();
|
public abstract double height();
|
||||||
public double posX() {
|
public double posX() {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
public double posY() {
|
public double posY() {
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void draw(Graphics2D g2);
|
public abstract void draw(Graphics2D g2);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Shape o) {
|
public int compareTo(Shape o) {
|
||||||
return Double.compare(width() * height(), o.width() * o.height());
|
return Double.compare(width() * height(), o.width() * o.height());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
package shape;
|
package shape;
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author radaelli11353
|
* @author radaelli11353
|
||||||
*/
|
*/
|
||||||
public class ShapesViewer {
|
public class ShapesViewer {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
JFrame frame = new JFrame();
|
JFrame frame = new JFrame();
|
||||||
|
|
||||||
frame.setSize(600, 600);
|
frame.setSize(600, 600);
|
||||||
frame.setTitle("Circles");
|
frame.setTitle("Circles");
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
|
||||||
Tester component = new Tester();
|
Tester component = new Tester();
|
||||||
frame.add(component);
|
frame.add(component);
|
||||||
|
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,50 +1,50 @@
|
||||||
package shape;
|
package shape;
|
||||||
|
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author radaelli11353
|
* @author radaelli11353
|
||||||
*/
|
*/
|
||||||
public class Square extends Shape {
|
public class Square extends Shape {
|
||||||
private double l;
|
private double l;
|
||||||
|
|
||||||
public Square(double x, double y, double l) {
|
public Square(double x, double y, double l) {
|
||||||
super(x, y);
|
super(x, y);
|
||||||
this.l = l;
|
this.l = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double width() {
|
public double width() {
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double height() {
|
public double height() {
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int hash = 7;
|
int hash = 7;
|
||||||
hash = 97 * hash + (int) (Double.doubleToLongBits(this.l) ^ (Double.doubleToLongBits(this.l) >>> 32));
|
hash = 97 * hash + (int) (Double.doubleToLongBits(this.l) ^ (Double.doubleToLongBits(this.l) >>> 32));
|
||||||
hash = 97 * hash + super.hashCode();
|
hash = 97 * hash + super.hashCode();
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (o == null) return false;
|
if (o == null) return false;
|
||||||
if (getClass() != o.getClass()) return false;
|
if (getClass() != o.getClass()) return false;
|
||||||
Square s = (Square) o;
|
Square s = (Square) o;
|
||||||
return l == s.l;
|
return l == s.l;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2) {
|
public void draw(Graphics2D g2) {
|
||||||
Rectangle r = new Rectangle((int)posX(), (int)posY(), (int)width(), (int)height());
|
Rectangle r = new Rectangle((int)posX(), (int)posY(), (int)width(), (int)height());
|
||||||
|
|
||||||
g2.draw(r);
|
g2.draw(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
package shape;
|
package shape;
|
||||||
|
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author radaelli11353
|
* @author radaelli11353
|
||||||
*/
|
*/
|
||||||
public class Tester extends JComponent{
|
public class Tester extends JComponent{
|
||||||
public void paintComponent(Graphics g) {
|
public void paintComponent(Graphics g) {
|
||||||
Graphics2D g2 = (Graphics2D) g;
|
Graphics2D g2 = (Graphics2D) g;
|
||||||
|
|
||||||
Geometria geom = new Geometria();
|
Geometria geom = new Geometria();
|
||||||
|
|
||||||
geom.riempiACaso(10);
|
geom.riempiACaso(10);
|
||||||
|
|
||||||
geom.draw(g2);
|
geom.draw(g2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,62 +1,62 @@
|
||||||
package shape;
|
package shape;
|
||||||
|
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.geom.Line2D;
|
import java.awt.geom.Line2D;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author radaelli11353
|
* @author radaelli11353
|
||||||
*/
|
*/
|
||||||
public class TriangoloRettangolo extends Shape {
|
public class TriangoloRettangolo extends Shape {
|
||||||
private double b;
|
private double b;
|
||||||
private double h;
|
private double h;
|
||||||
|
|
||||||
public TriangoloRettangolo(double x, double y, double b, double h) {
|
public TriangoloRettangolo(double x, double y, double b, double h) {
|
||||||
super(x, y);
|
super(x, y);
|
||||||
this.b = b;
|
this.b = b;
|
||||||
this.h = h;
|
this.h = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double width() {
|
public double width() {
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double height() {
|
public double height() {
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int hash = 3;
|
int hash = 3;
|
||||||
hash = 53 * hash + (int) (Double.doubleToLongBits(this.b) ^ (Double.doubleToLongBits(this.b) >>> 32));
|
hash = 53 * hash + (int) (Double.doubleToLongBits(this.b) ^ (Double.doubleToLongBits(this.b) >>> 32));
|
||||||
hash = 53 * hash + (int) (Double.doubleToLongBits(this.h) ^ (Double.doubleToLongBits(this.h) >>> 32));
|
hash = 53 * hash + (int) (Double.doubleToLongBits(this.h) ^ (Double.doubleToLongBits(this.h) >>> 32));
|
||||||
hash = 53 * hash + super.hashCode();
|
hash = 53 * hash + super.hashCode();
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (o == null || getClass() != o.getClass()) {
|
if (o == null || getClass() != o.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
TriangoloRettangolo t = (TriangoloRettangolo) o;
|
TriangoloRettangolo t = (TriangoloRettangolo) o;
|
||||||
if (Double.doubleToLongBits(b) != Double.doubleToLongBits(t.b)) {
|
if (Double.doubleToLongBits(b) != Double.doubleToLongBits(t.b)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return Double.doubleToLongBits(h) != Double.doubleToLongBits(t.h);
|
return Double.doubleToLongBits(h) != Double.doubleToLongBits(t.h);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2) {
|
public void draw(Graphics2D g2) {
|
||||||
Line2D.Double altezza = new Line2D.Double(posX(), posY(), posX(), posY()+height());
|
Line2D.Double altezza = new Line2D.Double(posX(), posY(), posX(), posY()+height());
|
||||||
Line2D.Double base = new Line2D.Double(posX(), posY()+height(), posX()+width(), posY()+height());
|
Line2D.Double base = new Line2D.Double(posX(), posY()+height(), posX()+width(), posY()+height());
|
||||||
Line2D.Double ipotenusa = new Line2D.Double(posX(), posY(), posX()+width(), posY()+height());
|
Line2D.Double ipotenusa = new Line2D.Double(posX(), posY(), posX()+width(), posY()+height());
|
||||||
|
|
||||||
g2.draw(altezza);
|
g2.draw(altezza);
|
||||||
g2.draw(base);
|
g2.draw(base);
|
||||||
g2.draw(ipotenusa);
|
g2.draw(ipotenusa);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* 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 timer.DateViewer;
|
||||||
|
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.util.Date;
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author radaelli11353
|
||||||
|
*/
|
||||||
|
public class DateComponent extends JComponent {
|
||||||
|
private Date now;
|
||||||
|
|
||||||
|
public DateComponent() {
|
||||||
|
now = new Date();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void paintComponent(Graphics g) {
|
||||||
|
Graphics2D g2 = (Graphics2D) g;
|
||||||
|
recalculateDate();
|
||||||
|
g2.drawString(now.toString(), 100, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void recalculateDate() {
|
||||||
|
now = new Date();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* 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 timer.DateViewer;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.Timer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author radaelli11353
|
||||||
|
*/
|
||||||
|
public class DateFrame extends JFrame {
|
||||||
|
private static final int FRAME_WIDTH = 300;
|
||||||
|
private static final int FRAME_HEIGHT = 400;
|
||||||
|
|
||||||
|
private DateComponent scene;
|
||||||
|
|
||||||
|
public DateFrame() {
|
||||||
|
scene = new DateComponent();
|
||||||
|
add(scene);
|
||||||
|
|
||||||
|
setSize(FRAME_WIDTH, FRAME_HEIGHT);
|
||||||
|
|
||||||
|
final int DELAY = 100;
|
||||||
|
Timer t = new Timer(DELAY, e -> {
|
||||||
|
scene.repaint();
|
||||||
|
});
|
||||||
|
t.start();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
/*
|
||||||
|
* 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 timer.DateViewer;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author radaelli11353
|
||||||
|
*/
|
||||||
|
public class DateViewer {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
JFrame frame = new DateFrame();
|
||||||
|
frame.setTitle("Date and Hour");
|
||||||
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
frame.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* 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 timer.MovingRectangle;
|
||||||
|
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author radaelli11353
|
||||||
|
*/
|
||||||
|
public class RectangleComponent extends JComponent{
|
||||||
|
private static final int BOX_X = 100;
|
||||||
|
private static final int BOX_Y = 100;
|
||||||
|
private static final int BOX_WIDTH = 20;
|
||||||
|
private static final int BOX_HEIGHT = 30;
|
||||||
|
|
||||||
|
private Rectangle box;
|
||||||
|
|
||||||
|
public RectangleComponent() {
|
||||||
|
box = new Rectangle(BOX_X, BOX_Y, BOX_WIDTH, BOX_HEIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void paintComponent(Graphics g) {
|
||||||
|
Graphics2D g2 = (Graphics2D) g;
|
||||||
|
g2.draw(box);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void moveRectangleBy(int dx, int dy) {
|
||||||
|
box.translate(dx, dy);
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* 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 timer.MovingRectangle;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.Timer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author radaelli11353
|
||||||
|
*/
|
||||||
|
public class RectangleFrame extends JFrame {
|
||||||
|
private static final int FRAME_WIDTH = 300;
|
||||||
|
private static final int FRAME_HEIGHT = 400;
|
||||||
|
|
||||||
|
private RectangleComponent scene;
|
||||||
|
|
||||||
|
public RectangleFrame() {
|
||||||
|
scene = new RectangleComponent();
|
||||||
|
add(scene);
|
||||||
|
|
||||||
|
setSize(FRAME_WIDTH, FRAME_HEIGHT);
|
||||||
|
|
||||||
|
final int DELAY = 100;
|
||||||
|
Timer t = new Timer(DELAY, e -> {
|
||||||
|
scene.moveRectangleBy(1, 1);
|
||||||
|
});
|
||||||
|
t.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* 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 timer.MovingRectangle;
|
||||||
|
|
||||||
|
import timer.MovingRectangleBorders.RectangleFrame;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author radaelli11353
|
||||||
|
*/
|
||||||
|
public class RectangleViewer {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
JFrame frame = new RectangleFrame();
|
||||||
|
frame.setTitle("An animated rectangle");
|
||||||
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
frame.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* 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 timer.MovingRectangleBorders;
|
||||||
|
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author radaelli11353
|
||||||
|
*/
|
||||||
|
public class RectangleComponent extends JComponent{
|
||||||
|
private static final int BOX_X = 100;
|
||||||
|
private static final int BOX_Y = 100;
|
||||||
|
private static final int BOX_WIDTH = 20;
|
||||||
|
private static final int BOX_HEIGHT = 30;
|
||||||
|
|
||||||
|
private Rectangle box;
|
||||||
|
private int xMov = 1;
|
||||||
|
private int yMov = 1;
|
||||||
|
|
||||||
|
public RectangleComponent() {
|
||||||
|
box = new Rectangle(BOX_X, BOX_Y, BOX_WIDTH, BOX_HEIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void paintComponent(Graphics g) {
|
||||||
|
Graphics2D g2 = (Graphics2D) g;
|
||||||
|
g2.draw(box);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void moveRectangle() {
|
||||||
|
double x = box.getX();
|
||||||
|
double y = box.getY();
|
||||||
|
xMov = (x + box.getWidth() < getWidth()) ? xMov : -1;
|
||||||
|
yMov = (y + box.getHeight() < getHeight()) ? yMov : -1;
|
||||||
|
xMov = (x >= 0) ? xMov : 1;
|
||||||
|
yMov = (y >= 0) ? yMov : 1;
|
||||||
|
|
||||||
|
box.translate(xMov, yMov);
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* 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 timer.MovingRectangleBorders;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.Timer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author radaelli11353
|
||||||
|
*/
|
||||||
|
public class RectangleFrame extends JFrame {
|
||||||
|
public static final int FRAME_WIDTH = 300;
|
||||||
|
public static final int FRAME_HEIGHT = 400;
|
||||||
|
|
||||||
|
private RectangleComponent scene;
|
||||||
|
|
||||||
|
public RectangleFrame() {
|
||||||
|
scene = new RectangleComponent();
|
||||||
|
add(scene);
|
||||||
|
|
||||||
|
setSize(FRAME_WIDTH, FRAME_HEIGHT);
|
||||||
|
|
||||||
|
final int DELAY = 100;
|
||||||
|
Timer t = new Timer(DELAY, e -> {
|
||||||
|
scene.moveRectangle();
|
||||||
|
});
|
||||||
|
t.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
/*
|
||||||
|
* 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 timer.MovingRectangleBorders;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author radaelli11353
|
||||||
|
*/
|
||||||
|
public class RectangleViewer {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
JFrame frame = new RectangleFrame();
|
||||||
|
frame.setTitle("An animated rectangle");
|
||||||
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
frame.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- You may freely edit this file. See commented blocks below for -->
|
||||||
|
<!-- some examples of how to customize the build. -->
|
||||||
|
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
||||||
|
<!-- By default, only the Clean and Build commands use this build script. -->
|
||||||
|
<!-- Commands such as Run, Debug, and Test only use this build script if -->
|
||||||
|
<!-- the Compile on Save feature is turned off for the project. -->
|
||||||
|
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
||||||
|
<!-- in the project's Project Properties dialog box.-->
|
||||||
|
<project name="Ricorsione" default="default" basedir=".">
|
||||||
|
<description>Builds, tests, and runs the project Ricorsione.</description>
|
||||||
|
<import file="nbproject/build-impl.xml"/>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
There exist several targets which are by default empty and which can be
|
||||||
|
used for execution of your tasks. These targets are usually executed
|
||||||
|
before and after some main targets. They are:
|
||||||
|
|
||||||
|
-pre-init: called before initialization of project properties
|
||||||
|
-post-init: called after initialization of project properties
|
||||||
|
-pre-compile: called before javac compilation
|
||||||
|
-post-compile: called after javac compilation
|
||||||
|
-pre-compile-single: called before javac compilation of single file
|
||||||
|
-post-compile-single: called after javac compilation of single file
|
||||||
|
-pre-compile-test: called before javac compilation of JUnit tests
|
||||||
|
-post-compile-test: called after javac compilation of JUnit tests
|
||||||
|
-pre-compile-test-single: called before javac compilation of single JUnit test
|
||||||
|
-post-compile-test-single: called after javac compilation of single JUunit test
|
||||||
|
-pre-jar: called before JAR building
|
||||||
|
-post-jar: called after JAR building
|
||||||
|
-post-clean: called after cleaning build products
|
||||||
|
|
||||||
|
(Targets beginning with '-' are not intended to be called on their own.)
|
||||||
|
|
||||||
|
Example of inserting an obfuscator after compilation could look like this:
|
||||||
|
|
||||||
|
<target name="-post-compile">
|
||||||
|
<obfuscate>
|
||||||
|
<fileset dir="${build.classes.dir}"/>
|
||||||
|
</obfuscate>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
For list of available properties check the imported
|
||||||
|
nbproject/build-impl.xml file.
|
||||||
|
|
||||||
|
|
||||||
|
Another way to customize the build is by overriding existing main targets.
|
||||||
|
The targets of interest are:
|
||||||
|
|
||||||
|
-init-macrodef-javac: defines macro for javac compilation
|
||||||
|
-init-macrodef-junit: defines macro for junit execution
|
||||||
|
-init-macrodef-debug: defines macro for class debugging
|
||||||
|
-init-macrodef-java: defines macro for class execution
|
||||||
|
-do-jar: JAR building
|
||||||
|
run: execution of project
|
||||||
|
-javadoc-build: Javadoc generation
|
||||||
|
test-report: JUnit report generation
|
||||||
|
|
||||||
|
An example of overriding the target for project execution could look like this:
|
||||||
|
|
||||||
|
<target name="run" depends="Ricorsione-impl.jar">
|
||||||
|
<exec dir="bin" executable="launcher.exe">
|
||||||
|
<arg file="${dist.jar}"/>
|
||||||
|
</exec>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
Notice that the overridden target depends on the jar target and not only on
|
||||||
|
the compile target as the regular run target does. Again, for a list of available
|
||||||
|
properties which you can use, check the target you are overriding in the
|
||||||
|
nbproject/build-impl.xml file.
|
||||||
|
|
||||||
|
-->
|
||||||
|
</project>
|
|
@ -0,0 +1,3 @@
|
||||||
|
Manifest-Version: 1.0
|
||||||
|
X-COMMENT: Main-Class will be added automatically by build
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,8 @@
|
||||||
|
build.xml.data.CRC32=b3c20d1e
|
||||||
|
build.xml.script.CRC32=f1f4ef54
|
||||||
|
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=b3c20d1e
|
||||||
|
nbproject/build-impl.xml.script.CRC32=151ad6e6
|
||||||
|
nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.106.0.48
|
|
@ -0,0 +1,95 @@
|
||||||
|
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}/Ricorsione.jar
|
||||||
|
dist.javadoc.dir=${dist.dir}/javadoc
|
||||||
|
dist.jlink.dir=${dist.dir}/jlink
|
||||||
|
dist.jlink.output=${dist.jlink.dir}/Ricorsione
|
||||||
|
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=17
|
||||||
|
javac.target=17
|
||||||
|
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=Ricorsione
|
||||||
|
main.class=ricorsione.Ricorsione
|
||||||
|
manifest.file=manifest.mf
|
||||||
|
meta.inf.dir=${src.dir}/META-INF
|
||||||
|
mkdist.disabled=false
|
||||||
|
platform.active=Zulu_17.0.6_10
|
||||||
|
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
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||||
|
<type>org.netbeans.modules.java.j2seproject</type>
|
||||||
|
<configuration>
|
||||||
|
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
||||||
|
<name>Ricorsione</name>
|
||||||
|
<explicit-platform explicit-source-supported="true"/>
|
||||||
|
<source-roots>
|
||||||
|
<root id="src.dir"/>
|
||||||
|
</source-roots>
|
||||||
|
<test-roots>
|
||||||
|
<root id="test.src.dir"/>
|
||||||
|
</test-roots>
|
||||||
|
</data>
|
||||||
|
</configuration>
|
||||||
|
</project>
|
Loading…
Reference in New Issue