From c15bed02e34ec625a26c603658d19d0c6574b790 Mon Sep 17 00:00:00 2001 From: pujolman Date: Sat, 26 May 2018 17:30:35 +0200 Subject: [PATCH 1/8] New NetBeans Project --- .gitignore | 1 + JavaApplication1/build.xml | 73 + JavaApplication1/manifest.mf | 3 + JavaApplication1/nbproject/build-impl.xml | 1420 +++++++++++++++++ .../nbproject/genfiles.properties | 8 + JavaApplication1/nbproject/project.properties | 74 + JavaApplication1/nbproject/project.xml | 15 + .../javaapplication1/JavaApplication1.java | 21 + 8 files changed, 1615 insertions(+) create mode 100644 .gitignore create mode 100644 JavaApplication1/build.xml create mode 100644 JavaApplication1/manifest.mf create mode 100644 JavaApplication1/nbproject/build-impl.xml create mode 100644 JavaApplication1/nbproject/genfiles.properties create mode 100644 JavaApplication1/nbproject/project.properties create mode 100644 JavaApplication1/nbproject/project.xml create mode 100644 JavaApplication1/src/javaapplication1/JavaApplication1.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..23a0b0a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/JavaApplication1/nbproject/private/ \ No newline at end of file diff --git a/JavaApplication1/build.xml b/JavaApplication1/build.xml new file mode 100644 index 0000000..9a33201 --- /dev/null +++ b/JavaApplication1/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project JavaApplication1. + + + diff --git a/JavaApplication1/manifest.mf b/JavaApplication1/manifest.mf new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/JavaApplication1/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/JavaApplication1/nbproject/build-impl.xml b/JavaApplication1/nbproject/build-impl.xml new file mode 100644 index 0000000..c158f28 --- /dev/null +++ b/JavaApplication1/nbproject/build-impl.xml @@ -0,0 +1,1420 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/JavaApplication1/nbproject/genfiles.properties b/JavaApplication1/nbproject/genfiles.properties new file mode 100644 index 0000000..f6e6d1e --- /dev/null +++ b/JavaApplication1/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=3569ad16 +build.xml.script.CRC32=360ae6d5 +build.xml.stylesheet.CRC32=8064a381@1.80.1.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=3569ad16 +nbproject/build-impl.xml.script.CRC32=3e9f3573 +nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48 diff --git a/JavaApplication1/nbproject/project.properties b/JavaApplication1/nbproject/project.properties new file mode 100644 index 0000000..a16b614 --- /dev/null +++ b/JavaApplication1/nbproject/project.properties @@ -0,0 +1,74 @@ +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.test.classpath=\ + ${run.test.classpath} +# 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}/JavaApplication1.jar +dist.javadoc.dir=${dist.dir}/javadoc +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=true +javac.processorpath=\ + ${javac.classpath} +javac.source=1.8 +javac.target=1.8 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +main.class=javaapplication1.JavaApplication1 +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.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/JavaApplication1/nbproject/project.xml b/JavaApplication1/nbproject/project.xml new file mode 100644 index 0000000..b466dd5 --- /dev/null +++ b/JavaApplication1/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + JavaApplication1 + + + + + + + + + diff --git a/JavaApplication1/src/javaapplication1/JavaApplication1.java b/JavaApplication1/src/javaapplication1/JavaApplication1.java new file mode 100644 index 0000000..32512e5 --- /dev/null +++ b/JavaApplication1/src/javaapplication1/JavaApplication1.java @@ -0,0 +1,21 @@ +/* + * 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 javaapplication1; + +/** + * + * @author Jorge + */ +public class JavaApplication1 { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + // TODO code application logic here + } + +} From f9114a9fc90f4722434adae6ca120462ed9585f5 Mon Sep 17 00:00:00 2001 From: pujolman Date: Sat, 26 May 2018 17:49:14 +0200 Subject: [PATCH 2/8] Added class Cuenta --- .../src/javaapplication1/Cuenta.java | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 JavaApplication1/src/javaapplication1/Cuenta.java diff --git a/JavaApplication1/src/javaapplication1/Cuenta.java b/JavaApplication1/src/javaapplication1/Cuenta.java new file mode 100644 index 0000000..71e7bd8 --- /dev/null +++ b/JavaApplication1/src/javaapplication1/Cuenta.java @@ -0,0 +1,60 @@ +/* + * 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 javaapplication1; + +/** + * + * @author Jorge + */ +public class Cuenta { + + public String titular; + public Double cantidad; + + public Cuenta(String getTitular) { + titular = getTitular; + } + + public String getTitular() { + return titular; + } + + public void setTitular(String tit) { + this.titular = tit; + } + + public String toStringTitular() { + return "Accede o setea el nombre del titular de la cuenta"; + } + + public Double getCantidad() { + return cantidad; + } + + public void setCantidad(Double cant) { + this.cantidad = cant; + } + + public String toStringCantidad() { + return "Accede o setea la cantidad de dinero de la cuenta"; + } + + public void ingresar(Double cant) { + if(cant > 0){ + this.cantidad += cant; + } + } + + public void retirar(Double cant) { + + if(cant > this.cantidad){ + this.cantidad = 0.00; + }else{ + this.cantidad -= cant; + } + } + +} From 57cb93158edb17e2be9b0cced8e66b8158126386 Mon Sep 17 00:00:00 2001 From: pujolman Date: Sat, 26 May 2018 18:04:13 +0200 Subject: [PATCH 3/8] Changed/Added contructors --- JavaApplication1/src/javaapplication1/Cuenta.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/JavaApplication1/src/javaapplication1/Cuenta.java b/JavaApplication1/src/javaapplication1/Cuenta.java index 71e7bd8..b03a008 100644 --- a/JavaApplication1/src/javaapplication1/Cuenta.java +++ b/JavaApplication1/src/javaapplication1/Cuenta.java @@ -14,8 +14,15 @@ public class Cuenta { public String titular; public Double cantidad; + public Cuenta(String getTitular) { titular = getTitular; + cantidad = 0.00; + } + + public Cuenta(String getTitular, Double getCant) { + titular = getTitular; + cantidad = getCant; } public String getTitular() { From 84c4aa4fff432764d097655c6ed53e2e8d0985d8 Mon Sep 17 00:00:00 2001 From: pujolman Date: Sat, 26 May 2018 18:07:02 +0200 Subject: [PATCH 4/8] Added "this" before parameters --- JavaApplication1/src/javaapplication1/Cuenta.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/JavaApplication1/src/javaapplication1/Cuenta.java b/JavaApplication1/src/javaapplication1/Cuenta.java index b03a008..bfe4559 100644 --- a/JavaApplication1/src/javaapplication1/Cuenta.java +++ b/JavaApplication1/src/javaapplication1/Cuenta.java @@ -16,13 +16,13 @@ public class Cuenta { public Cuenta(String getTitular) { - titular = getTitular; - cantidad = 0.00; + this.titular = getTitular; + this.cantidad = 0.00; } public Cuenta(String getTitular, Double getCant) { - titular = getTitular; - cantidad = getCant; + this.titular = getTitular; + this.cantidad = getCant; } public String getTitular() { From 0b348f1f57491e96f0731fa5c7dcd510ec0b816d Mon Sep 17 00:00:00 2001 From: pujolman Date: Sat, 26 May 2018 18:27:41 +0200 Subject: [PATCH 5/8] Added calls to cuenta class in JavaApplication1 --- .../src/javaapplication1/JavaApplication1.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/JavaApplication1/src/javaapplication1/JavaApplication1.java b/JavaApplication1/src/javaapplication1/JavaApplication1.java index 32512e5..8e58ae7 100644 --- a/JavaApplication1/src/javaapplication1/JavaApplication1.java +++ b/JavaApplication1/src/javaapplication1/JavaApplication1.java @@ -11,11 +11,19 @@ */ public class JavaApplication1 { - /** - * @param args the command line arguments - */ - public static void main(String[] args) { + public Cuenta cuenta; + + public void main(String[] args) { // TODO code application logic here + + cuenta = new Cuenta("Jorge Lopez"); + + cuenta.setCantidad(500.30); + + cuenta.ingresar(35.27); + + cuenta.retirar(314.00); + } } From 85a45dd94d021a0194bc1e07ec153ffc577a5d82 Mon Sep 17 00:00:00 2001 From: pujolman Date: Sat, 26 May 2018 19:12:28 +0200 Subject: [PATCH 6/8] Added Class persona --- .../src/javaapplication1/Persona.java | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 JavaApplication1/src/javaapplication1/Persona.java diff --git a/JavaApplication1/src/javaapplication1/Persona.java b/JavaApplication1/src/javaapplication1/Persona.java new file mode 100644 index 0000000..bb9630d --- /dev/null +++ b/JavaApplication1/src/javaapplication1/Persona.java @@ -0,0 +1,123 @@ +/* + * 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 javaapplication1; + +import java.util.Random; + +/** + * + * @author Jorge + */ +public class Persona { + + private String nombre; + private Integer edad; + private String dni; + private char sexo; + private Double peso; + private Double altura; + static final char[] LETTERS = {'T', 'R', 'W', 'A', 'G', 'M', 'Y', 'F', 'P', 'D', 'X','B', 'N', 'J', 'Z', 'S', 'Q', 'V', 'H', 'L', 'C', 'K', 'E'}; + + public Persona() { + this.nombre = ""; + this.edad = 0; + this.dni = ""; + this.sexo = 'M'; + this.peso = 0.00; + this.altura = 0.00; + } + + public Persona(String nombre, Integer edad, char sexo) { + this.nombre = nombre; + this.edad = edad; + this.dni = ""; + this.sexo = sexo; + this.peso = 0.00; + this.altura = 0.00; + } + + public Persona(String nombre, Integer edad, String dni, char sexo, Double peso, Double altura) { + this.nombre = nombre; + this.edad = edad; + this.dni = dni; + this.sexo = sexo; + this.peso = peso; + this.altura = altura; + } + + public Integer calcularIMC(Double peso, Double altura) { + Double total = peso / (altura * altura); + if (total > 25) { + return 1; + } else if (total >= 20) { + return 0; + } else { + return -1; + } + } + + public Boolean esMayorDeEdad(Integer edad) { + if (edad >= 18) { + return true; + } else { + return false; + } + } + + private char comprobarSexo(char sexo) { + if (sexo != 'M' || sexo != 'H') { + return 'H'; + } else { + return sexo; + } + } + + public String toString() { + return "Nombre: el nombre de la persona" + + "Edad: la edad de la persona" + + "Dni: el número de identificación de la persona" + + "Sexo: Hombre(H) o Mujer(M) , (por defecto Hombre)" + + "peso: peso en kg" + + "altura: estatura en metros"; + } + + public String generaDNI() { + Integer numeros = randomNumber(); + String dni = addLetter(numeros); + return dni; + } + + public Integer randomNumber() { + + int r = (int) (Math.random() * (99999999 - 100000000)) + 100000000; + return r; + + } + + public String addLetter(Integer numeros){ + int resto = numeros % 23; + char letra = LETTERS[resto]; + String dni = Integer.toString(resto) + Character.toString(letra); + return dni; + } + + public void setNombre(String nombre) { + this.nombre = nombre; + } + public void setEdad(Integer edad) { + this.edad = edad; + } + public void setSexo(char sexo) { + this.sexo = sexo; + } + public void setPeso(Double peso) { + this.peso = peso; + } + public void setAltura(Double altura) { + this.altura = altura; + } + +} From 01c55dfb587711a465eb1f42f2e1bd9e397e096d Mon Sep 17 00:00:00 2001 From: pujolman Date: Sat, 26 May 2018 19:21:29 +0200 Subject: [PATCH 7/8] second java --- .../javaapplication1/JavaApplication2.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 JavaApplication1/src/javaapplication1/JavaApplication2.java diff --git a/JavaApplication1/src/javaapplication1/JavaApplication2.java b/JavaApplication1/src/javaapplication1/JavaApplication2.java new file mode 100644 index 0000000..dd90222 --- /dev/null +++ b/JavaApplication1/src/javaapplication1/JavaApplication2.java @@ -0,0 +1,32 @@ +/* + * 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 javaapplication1; + +/** + * + * @author Jorge + */ +public class JavaApplication2 { + + public Persona personaObj1; + public Persona personaObj2; + public Persona personaObj3; + + public void main(String[] args) { + // TODO code application logic here + + String nombre = "Jorge"; + Integer edad = 27; + char sexo = 'H'; + Double peso = 56.5; + Double altura = 1.67; + + + + + } + +} From 9b44779417081ded4980657c333245ef423ec4ed Mon Sep 17 00:00:00 2001 From: pujolman Date: Sat, 26 May 2018 19:27:09 +0200 Subject: [PATCH 8/8] pr changes --- .../src/javaapplication1/Cuenta.java | 16 ++++++++++------ .../src/javaapplication1/JavaApplication1.java | 5 +++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/JavaApplication1/src/javaapplication1/Cuenta.java b/JavaApplication1/src/javaapplication1/Cuenta.java index bfe4559..d6dd127 100644 --- a/JavaApplication1/src/javaapplication1/Cuenta.java +++ b/JavaApplication1/src/javaapplication1/Cuenta.java @@ -11,8 +11,8 @@ */ public class Cuenta { - public String titular; - public Double cantidad; + private String titular; + private Double cantidad; public Cuenta(String getTitular) { @@ -22,7 +22,11 @@ public Cuenta(String getTitular) { public Cuenta(String getTitular, Double getCant) { this.titular = getTitular; - this.cantidad = getCant; + if(getCant < 0){ + this.cantidad = 0.00; + }else{ + this.cantidad = getCant; + } } public String getTitular() { @@ -57,10 +61,10 @@ public void ingresar(Double cant) { public void retirar(Double cant) { - if(cant > this.cantidad){ + this.cantidad -= cant; + + if(this.cantidad < 0){ this.cantidad = 0.00; - }else{ - this.cantidad -= cant; } } diff --git a/JavaApplication1/src/javaapplication1/JavaApplication1.java b/JavaApplication1/src/javaapplication1/JavaApplication1.java index 8e58ae7..818f9db 100644 --- a/JavaApplication1/src/javaapplication1/JavaApplication1.java +++ b/JavaApplication1/src/javaapplication1/JavaApplication1.java @@ -4,7 +4,6 @@ * and open the template in the editor. */ package javaapplication1; - /** * * @author Jorge @@ -12,17 +11,19 @@ public class JavaApplication1 { public Cuenta cuenta; + public Cuenta cuenta2; public void main(String[] args) { // TODO code application logic here cuenta = new Cuenta("Jorge Lopez"); + cuenta2 = new Cuenta("Jorge Lopez", 235.10); cuenta.setCantidad(500.30); cuenta.ingresar(35.27); - cuenta.retirar(314.00); + cuenta2.retirar(314.00); }