From e644b9242a1a5415e611cdbe5a87503129c931c0 Mon Sep 17 00:00:00 2001 From: daniorta <148881254+daniorta@users.noreply.github.com> Date: Mon, 24 Mar 2025 22:53:43 +0100 Subject: [PATCH 1/3] first commit --- .idea/.gitignore | 3 + .idea/lab-java-basics-es.iml | 11 ++ .idea/misc.xml | 6 + .idea/modules.xml | 8 + .idea/vcs.xml | 6 + out/production/lab-java-basics-es/Main.class | Bin 0 -> 3807 bytes .../employer/Employer.class | Bin 0 -> 1322 bytes .../lab-java-basics-es/employer/Intern.class | Bin 0 -> 895 bytes src/Main.java | 143 ++++++++++++++++++ src/employer/Employer.java | 62 ++++++++ src/employer/Intern.java | 33 ++++ 11 files changed, 272 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/lab-java-basics-es.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 out/production/lab-java-basics-es/Main.class create mode 100644 out/production/lab-java-basics-es/employer/Employer.class create mode 100644 out/production/lab-java-basics-es/employer/Intern.class create mode 100644 src/Main.java create mode 100644 src/employer/Employer.java create mode 100644 src/employer/Intern.java diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/lab-java-basics-es.iml b/.idea/lab-java-basics-es.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/.idea/lab-java-basics-es.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..47478b9 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..b936c40 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/out/production/lab-java-basics-es/Main.class b/out/production/lab-java-basics-es/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..362252743c5900493bec112149ab7c8434cca342 GIT binary patch literal 3807 zcmaJ^TW}lI8UBuSSy_l=qe#I5hb+y_Mu{8(31G(_JCQ?_$ZO6EwoGUG*cqM}hC;t{B*&p~J7b;Q z{m%Kn|Np=9|7X{4eKda#z!1*H(T0$LZ~_rT1$+SVt8j&Zjs!BeQefp076Qh!vah}qoAOi1XslYQOeN#@*{z-nAAa79f{*}FWqEbDhT^`pEC>e8(T%C^vbsdW+pok^baBEx68V<_7GvWAF!?mV;Z_<}FY2DwjE$U=j*KM(E z%4Exm7g#e^tzidD+p2pN8CXFhP$tukU6B<#$i)qGQD9}DbnRIXIEHJvKO@pV|GJD0 z{`Fr>4~SzUa%ww!1UiHw_i=ASy3xVEKdtRz*d`D;U{`#P*zJ!fFov7y zpd{UjPX~YdT?_1|)O&5$Ib!=npHnNjbcp67(zUD6!FQk3n1Nw|4K? z;6ZJ`VD1uFH|EO;d5jACc3@R(t16Y|e2|t^7_&;bYA&wSI-J1WxQ8w#?Ruf23%#K5 z`x20tV6MdX%bG2a>RO^Q)Y3`CmLDpveS|!eK&$O0p{b8O@wea%-kk5mp7d zy9$?9S|PurlROS9l_u3NoxuIdU4q;rLwA;jibJ;@Od^Uv5woQ>F0t|di}rW|58wm? z4Hg3pcjZ;P7+^nycX<`&zP#wT_Wnj~!uH4HM3qRg=#^!4T>6fBZh_(YQHMs+qB*^#8SRULT(qQJdrK9Hg95Fbs) zt=MII$oJ*Uh@A2KCgdzYwyU7aOLbYE8j;gFW&@AY6UjZd?n{5TYS&2Wk#hMF#}Dc) zpy)k7vcTrD%Egf29w+Rkk@m|+w_zXm^rky1&OC$W!NlTc7Z?AlAE;4m0iq6z)5EQH z=YsZy1q>>6Xz3+RWoIKOv)Y+o(3o&4vK4@VQv&gl*YL~sZbxlgyV{$aIzpMzPS30J z?2*$WcKxVV31WCrAX9KF6wRtB4cR+YODaiwEfK@4z?BQrO3%eo!qvUEAMPl|f(!2F?hqza*!n zLN)Mf3ikh(sxwCCg==_DwdsRD!k09^V>o`A&po^fUL)6@fp~*AZTJjFH4VP6Kg%)E zT!07h5TDxdFdiYIj0;??NH0GN}b7C|bHMfms4fD>?Y$(^y z-$1rEoC%-X9tmxarlaY|Ec!FybTqf!NE@9mBb_$-$<{fKs{k^dMn~FMJ&R=87$ClS z9&0pyGAd4g{71ENb!8rw##BNft;&9^cZLKe*O#T!&6{u`V~! zau{o|kH~(k=bN(&Wpv{Ru7%IJ6O{ciY|(<;KnaGi87J`tO2wpGIw$DyF+K^}-is$V z+eY3)_#*E@_!3uI2!D(lVHoP~%R=Y@_z>&G2S~k7UV*P%5OoKwBD4yWsMk;eqbcf5 z6xCctRjF*$%ql&z;oK~iX<@^;fz!B*fYvy&J)90_&&{GEn-1qXXA$olPy``*4Lt^{PR0<;|Efq#nVx#7o6mB(XtFU&Bl~fS7o9zlS+xt_v zW3Ni+AQQ^=Mlz9e+oK`XJ?ZEyp2|eh#@5~#7i3~{IHZPq)lgQ$k$D``8=Z;$0r_Wf zI1~Fl^1bbu_Bqr#Uqn&exZUNO;~jBz>plL=3%IJqrD@3EYlhQUlWFgW&!KT)TG`HH zMo*tKSZCg1L%OP+G0u9ri~mO*W=q_St+zC+(__%2@Hbt}F6l&s&=<4bz{z8-&|$J2UzRgXW` S=%p%zpp}Plx>g literal 0 HcmV?d00001 diff --git a/out/production/lab-java-basics-es/employer/Employer.class b/out/production/lab-java-basics-es/employer/Employer.class new file mode 100644 index 0000000000000000000000000000000000000000..8ba48e86708550265d6901f20dedd96f48e97871 GIT binary patch literal 1322 zcmZ`(U2hUm5Iq-`MQ|yFmVRrkRe?o|+8RyTG-;$wNJurQ>H9)AxD5reP-EZxK_+S< zG4a74;Eyt%xol~&Y(ug$ckawNbM8#|`|tN300(%LMhx*J3=0XE3bW_VC#TwRy6x(_ z=DFJ%Dwum-*BkCD#7pJV6z(9EMB2h#SPD7!qTlIVxqkI9a1@NLbKxrF8#hoVL*MJR zccpm7LKd?GbJ|Q&b&2II%we8P1E=HoR}9xAykKEbQe$;}T(+;D=TIPJIJWWU`OgIpQe6+ekipP^c93wS_3?qjVA!Ee%T0w$0^)p5W z*BpfiO(Mu-h9)seT40LjYZjwala%yH@6vC%N1o`+Tn}kWMuQE$UW{8{^2=$`i^*)X z@sT)p?k?bLZZ3&$)NL|NQ(FKnJZH5-?08^GG2ru%gBjFE~|U zdv9(Cq#wAx8$A@LHhRzHE7|s>KWg`*(Dg?#qS!9qkk;`KVd4c6~5XX;H=nG`` zJ5T$aUgz*gKsf0~Ki;r9V4^6nwZL>dPmQG42}iTB@}s@iLp6!qz|Wv0P~Y>csq|#% z29_UKlbJeE)>MVoSe^!<^>U`Hdw02VSjL)`Qx+)yhp|1-n%DEFVuQ@4D(Y+0Q-Nfo zYYzkpyMaHAq#q5WH&X_1VDW7?I8l_=bA5F%8y~Cii9Gh`DfNP(^aiA*?{jA|dge~q z&EADh>=4M8<2Y?0d)`U`Lyq{Aj#ZM6=n5npZiRj%hcEW!B!)L(3luM=3*<*C`m4`I z!*&F6{a_Xj)niw4UHUVRmd?d>4lThUP=X#C&r7@|a2W<|{s!)w^t_{$=2>fQZ`$S5 z8ANmC!1@H!UPIySdlbH4`KYvVhShH$8D`)L_X+`k9I{L;61<86wrE|Y_kR3V!!=mE z5tvlASWH_r#%fYE+`vs@Y3mk!Db#6~Abv44Wg=suAq<@((8TtfYKy1#B}woD&qT~c z3jtQ++FB;x=e7Bzu|bcPDe2Yqs`Y indeceArrayMayor){ + indeceArrayMayor = entero; + System.out.println("Indice mayor del array: " +indeceArrayMayor); + + } + else if(entero < indiceArrayMenor){ + indiceArrayMenor = entero; + System.out.println("Indice menor del array : " + indiceArrayMenor); + + } + + } + System.out.println("Diferencia entre el indice menor y el indice mayor: " + (indeceArrayMayor - indiceArrayMenor)); + } + + public void encontrarElementos() { + System.out.println("\nTarea 2."); + //Escribe un método en Java para encontrar el elemento más pequeño + // y el segundo más pequeño de un array dado e imprimirlo en la consola. + // Utiliza bucles y condicionales para desarrollar el algoritmo. + + int[] elementArray = new int[4]; + + elementArray[0] = 56; + elementArray[1] = 14; + elementArray[2] = 3; + elementArray[3] = 43; + + int firstElementLow, secondElementLow; + + if (elementArray[0] < elementArray[1]){ + firstElementLow = elementArray[0]; + secondElementLow = elementArray[1]; + }else { + firstElementLow = elementArray[1]; + secondElementLow = elementArray[0]; + } + + for(int i = 2; i < elementArray.length; i++){ + + if (elementArray[i] < firstElementLow){ + secondElementLow = firstElementLow; + firstElementLow = elementArray[i]; + + } + } + System.out.println("El valor del elemento más bajo es " + firstElementLow); + System.out.println("El valor del segundo elemento más bajo es "+ secondElementLow); + } + + public void createTenEmployer(){ + System.out.println("Tare 5. Escribir un programa que cree 10 empleados y muestre todas sus propiedades.\n"); + + + //Creación de employer + Employer [] employers = new Employer[10]; + + employers[0] = new Employer("María", 24, 32700, 0); + employers[1] = new Employer("Juan", 35, 36000, 1); + employers[2] = new Employer("Pedro", 22, 35500, 2 ); + employers[3] = new Employer("Sandra", 43, 34300, 3 ); + employers[4] = new Employer("Jenifer", 33, 34000, 4 ); + employers[5] = new Employer("Manel", 45, 38000, 5 ); + + //creación de Intern + employers[6] = new Intern("Marcos", 18, 15000 , 6); + employers[7] = new Intern("Alejandra", 20, 20000 , 7); + employers[8] = new Intern("José", 31, 18000 , 8); + employers[9] = new Intern("Isabel", 22, 19000 , 9); + + + int idBuscado = 9; + double subidaSalario = 100; + + //Mostrar por consola empleados y sus datos + System.out.println("Trabajadores de la empresa IT S.l.\n"); + for(Employer employer : employers){ + System.out.println("ID: " + employer.getId() + " - " + employer.getName() + " de " + employer.getAge() + " años, salario -> " + employer.getSalary() + "€."); + + if(employer instanceof Intern){ + Intern intern = (Intern) employer; + + if(intern.getId() == idBuscado){ + double nuevoSalario = intern.getSalary() + subidaSalario; + + if (nuevoSalario > intern.getMAXSALARY()){ + System.out.println("\nEl salario actual de " + employer.getName() + " es de " + employer.getSalary() + "€," + " es el máximo permitido para un Intern." ); + + }else{ + //Si el salario no supera los 20000€ anuel, dejara sumar la cantidad sin superar + intern.setSalary(nuevoSalario); + System.out.println("\nEl nuevo salario de " + employer.getName() + " es " + intern.getSalary() + "€."); + + } + } + } + + } + + + + + } + + + + + +} diff --git a/src/employer/Employer.java b/src/employer/Employer.java new file mode 100644 index 0000000..0addd1d --- /dev/null +++ b/src/employer/Employer.java @@ -0,0 +1,62 @@ +package employer; + +public class Employer { + //Tarea 3. + + //Atributos + private String name; + private int age; + private double salary; + private int experience; + private String post; + private final int ID; + + //Constructor + public Employer(String name, int age, double salary, int ID){ + this.name = name; + this.age = age; + this.salary =salary; + this.ID = ID; + } + //getter + public String getName(){ + return name; + } + + public int getAge(){ + return age; + } + + public double getSalary(){ + return salary; + } + + public int getExperience(){ + return experience; + } + + public String getPost(){ + return post; + } + + public int getId(){ + return ID; + } + + + + + //setter + public void setName(String name){ + this.name = name; + } + + public void setAge(int age){ + this.age = age; + } + + public void setSalary(double salary){ + this.salary = salary; + } + +} diff --git a/src/employer/Intern.java b/src/employer/Intern.java new file mode 100644 index 0000000..8cabd2b --- /dev/null +++ b/src/employer/Intern.java @@ -0,0 +1,33 @@ +package employer; + +public class Intern extends Employer { + + //Atributos + private final int MAXSALARY = 20000; + + //constructor + public Intern(String name, int age, double salary, int ID){ + super(name, age, salary, ID); + + if(salary > MAXSALARY){ + throw new IllegalArgumentException("El salario no puede ser mayor que " + MAXSALARY); + } + + } + + public int getMAXSALARY() { + return MAXSALARY; + } + + //MEtodo para actualizar el salario con validación. + //Sobreescribimos el metodo setsalary + @Override + public void setSalary(double salary){ + if(salary > MAXSALARY){ + throw new IllegalArgumentException("El salario no puede ser mayor que " + MAXSALARY); + }else { + //Si el valor de salario de un intern no supera el maximo, se puede actualizar, simepre que no supere el MAXSalary + super.setSalary(salary); + } + } +} From 6a131a3c7c4dfc574b93ebc46d39d1fb47736dfc Mon Sep 17 00:00:00 2001 From: Dani <148881254+daniorta@users.noreply.github.com> Date: Thu, 27 Mar 2025 17:29:01 +0100 Subject: [PATCH 2/3] done --- labs.iml | 11 ++ out/production/lab-java-basics-es/Main.class | Bin 3807 -> 3838 bytes .../employer/Employer.class | Bin 1322 -> 1320 bytes .../lab-java-basics-es/employer/Intern.class | Bin 895 -> 895 bytes src/Main.java | 117 ++++++++---------- src/employer/Employer.java | 9 +- src/employer/Intern.java | 1 + 7 files changed, 66 insertions(+), 72 deletions(-) create mode 100644 labs.iml diff --git a/labs.iml b/labs.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/labs.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/out/production/lab-java-basics-es/Main.class b/out/production/lab-java-basics-es/Main.class index 362252743c5900493bec112149ab7c8434cca342..8dfe884eac36c2def0687c442e80a5dd4aad5678 100644 GIT binary patch delta 2329 zcmZ8hYj6}*7XI$cboWftA@7A8WPbqX+pv{gEI+= zuVGn4U0nnk*JU3r%eqE)@qv#-gMyDLe^_OerItU%N0op4p=FhpWhwgIJ0Vp0W6s?E z?sf|*$=co^<_QEk$DNGc`uQPc7erJ*Tjvht zvcxv-l3)-q21q%Xp`2sst)HEmK`XpgUvywG^}C&no7P*u*eBH)xmuufHqT^c%*|zj zxTu)rU^cI}zTc%ZO;llS5D9@$TiP8}5%kuN9#oe>TOt7Y(bfwxA7Fw~|v$bf4{Jhe_ zRcIHOH<)vsF}KIfoUN+Bc{TlAvn0;Kt7>~gxEj|OxYj}vod@#EV_gEl9)}L%mo%7I zi|Y-nv#=f;4xGAN@3F8Ey`B)w)jeVO&=bTa(lv_)%NoM)gBJmLu~{JH4Tuzr+^0&w z(%8p(!7_#7E3#kmdW62=_e@$&tHhHUs5sZ2X{{<@yq%GVgm2@h#4ZHF_YhgQX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MzPS30J z?2*$WcKxVV31WCrAX9KF6wRtB4cR+YODaiwEfK@4z?BQrO3%eo!qvUEAMPl|f(!2F?hqza*!n zLN)Mf3ikh(sxwCCg==_DwdsRD!k09^V>o`A&po^fUL)6@fp~*AZTJjFH4VP6Kg%)E zT!07h5TDxdFdiYIj0;??NH0GN}b7C|bHMfms4fD>?Y$(^y z-$1rEoC%-X9tmxarlaY|Ec!FybTqf!NE@9mBb_$-$<{fKs{k^dMn~FMJ&R=87$ClS z9&0pyGAd4g{71ENb!8rw##BNft;&9^cZLKe*O#T!&6{u`V~! zau{o|kH~(k=bN(&Wpv{Ru7%IJ6O{ciY|(<;KnaGi87J`tO2wpGIw$DyF+K^}-is$V z+eY3)_#*E@_!3uI2!D(lVHoP~%R=Y@_z>&G2S~k7UV*P%5OoKwBD4yWsMk;eqbcf5 z6xCctRjF*$%ql&z;oK~iX<@^;fz!B*fYvy&J)90_&&{GEn-1qXXA$olPy``*4Lt^{PR0<;|Efq#nVx#7o6mB(XtFU&Bl~fS7o9zlS+xt_v zW3Ni+AQQ^=Mlz9e+oK`XJ?ZEyp2|eh#@5~#7i3~{IHZPq)lgQ$k$D``8=Z;$0r_Wf zI1~Fl^1bbu_Bqr#Uqn&exZUNO;~jBz>plL=3%IJqrD@3EYlhQUlWFgW&!KT)TG`HH zMo*tKSZCg1L%OP+G0u9ri~mO*W=q_St+zC+(__%2@Hbt}F6l&s&=<4bz{z8-&|$J2UzRgXW` S=%p%zpp}Plx>g diff --git a/out/production/lab-java-basics-es/employer/Employer.class b/out/production/lab-java-basics-es/employer/Employer.class index 8ba48e86708550265d6901f20dedd96f48e97871..9995fb604e7f20043b5ee70b568946e257c57ca5 100644 GIT binary patch delta 138 zcmZ3*wSsHHWftbF{G^FDcCoXir9q~GqI>M>VR4HEE=pP46F>MlXF{*LQKSr>B+#0NImgFg_LKXJBCvVBlmBWZ+{EVh{#GNd}S0 zlbBK%#U~dsi%#ZYR%et3vpj(;c_7P%Q5noX4CJeWSd&=P8MVPewk#T~#tf_sCX=&R W+*!?mEQ`t8fGleu%VshYs~P~aY#+M- diff --git a/out/production/lab-java-basics-es/employer/Intern.class b/out/production/lab-java-basics-es/employer/Intern.class index 28fc8ae978aee076df1b58b61327865619eab891..8e8c3af8766f24d1c34a1fba40201c278e886bce 100644 GIT binary patch delta 53 zcmey*_MdG-I+Gwb11AGJg8&0Bg9HN~gA#+_L<0{{|Y2>Sp4 diff --git a/src/Main.java b/src/Main.java index 13b9718..686c2f5 100644 --- a/src/Main.java +++ b/src/Main.java @@ -3,21 +3,7 @@ public class Main { public static void main( String[] args){ - - Main main = new Main(); - -// main.calcularDiferencia(); -// main.encontrarElementos(); - main.createTenEmployer(); - } - - public void calcularDiferencia(){ - System.out.println("Tarea 1."); - //Escribe un método en Java para obtener la diferencia - // entre el valor más grande y el más pequeño en un array de enteros. - // La longitud del array debe ser 1 o mayor. Utiliza bucles y - // condicionales para desarrollar el algoritmo. - + //Array que vamos a utilizar en nuestro ejercicios tareas 1, 2. int[] enteros = new int[5]; enteros[0] = 12; enteros[1] = 3; @@ -25,10 +11,40 @@ public void calcularDiferencia(){ enteros[3] = 53; enteros[4] = 88; + //Creación de employers para tareas 3, 4, 5. + Employer [] employers = new Employer[10]; + + employers[0] = new Employer("María", 24, 32700, 0); + employers[1] = new Employer("Juan", 35, 36000, 1); + employers[2] = new Employer("Pedro", 22, 35500, 2 ); + employers[3] = new Employer("Sandra", 43, 34300, 3 ); + employers[4] = new Employer("Jenifer", 33, 34000, 4 ); + employers[5] = new Employer("Manel", 45, 38000, 5 ); + + //creación de Intern + employers[6] = new Intern("Marcos", 18, 15000 , 6); + employers[7] = new Intern("Alejandra", 20, 20000 , 7); + employers[8] = new Intern("José", 31, 18000 , 8); + employers[9] = new Intern("Isabel", 22, 19000 , 9); + + + Main main = new Main(); + main.calcularDiferencia(enteros); + main.encontrarElementos(enteros); + main.createTenEmployer(employers); + + } + //----------------------------- + //tarea 1. Escribe un método en Java para obtener la diferencia + // entre el valor más grande y el más pequeño en un array de enteros. + // La longitud del array debe ser 1 o mayor. Utiliza bucles y + // condicionales para desarrollar el algoritmo. + public void calcularDiferencia(int[] enteros){ + System.out.println("Tarea 1."); + int indeceArrayMayor = enteros[0]; int indiceArrayMenor = enteros[0]; - for(int entero : enteros){ //System.out.println(entero); @@ -40,68 +56,42 @@ public void calcularDiferencia(){ else if(entero < indiceArrayMenor){ indiceArrayMenor = entero; System.out.println("Indice menor del array : " + indiceArrayMenor); - } - } System.out.println("Diferencia entre el indice menor y el indice mayor: " + (indeceArrayMayor - indiceArrayMenor)); } - - public void encontrarElementos() { + //----------------------------- + //Tarea 2. Escribe un método en Java para encontrar el elemento más pequeño + // y el segundo más pequeño de un array dado e imprimirlo en la consola. + // Utiliza bucles y condicionales para desarrollar el algoritmo. + public void encontrarElementos(int[] enteros) { System.out.println("\nTarea 2."); - //Escribe un método en Java para encontrar el elemento más pequeño - // y el segundo más pequeño de un array dado e imprimirlo en la consola. - // Utiliza bucles y condicionales para desarrollar el algoritmo. - - int[] elementArray = new int[4]; - elementArray[0] = 56; - elementArray[1] = 14; - elementArray[2] = 3; - elementArray[3] = 43; int firstElementLow, secondElementLow; - if (elementArray[0] < elementArray[1]){ - firstElementLow = elementArray[0]; - secondElementLow = elementArray[1]; + if (enteros[0] < enteros[1]){ + firstElementLow = enteros[0]; + secondElementLow = enteros[1]; }else { - firstElementLow = elementArray[1]; - secondElementLow = elementArray[0]; + firstElementLow = enteros[1]; + secondElementLow = enteros[0]; } - for(int i = 2; i < elementArray.length; i++){ + for(int i = 2; i < enteros.length; i++){ - if (elementArray[i] < firstElementLow){ + if (enteros[i] < firstElementLow){ secondElementLow = firstElementLow; - firstElementLow = elementArray[i]; + firstElementLow = enteros[i]; } } System.out.println("El valor del elemento más bajo es " + firstElementLow); - System.out.println("El valor del segundo elemento más bajo es "+ secondElementLow); + System.out.println("El valor del segundo elemento más bajo es "+ secondElementLow +"\n"); } - - public void createTenEmployer(){ - System.out.println("Tare 5. Escribir un programa que cree 10 empleados y muestre todas sus propiedades.\n"); - - - //Creación de employer - Employer [] employers = new Employer[10]; - - employers[0] = new Employer("María", 24, 32700, 0); - employers[1] = new Employer("Juan", 35, 36000, 1); - employers[2] = new Employer("Pedro", 22, 35500, 2 ); - employers[3] = new Employer("Sandra", 43, 34300, 3 ); - employers[4] = new Employer("Jenifer", 33, 34000, 4 ); - employers[5] = new Employer("Manel", 45, 38000, 5 ); - - //creación de Intern - employers[6] = new Intern("Marcos", 18, 15000 , 6); - employers[7] = new Intern("Alejandra", 20, 20000 , 7); - employers[8] = new Intern("José", 31, 18000 , 8); - employers[9] = new Intern("Isabel", 22, 19000 , 9); - + //Tarea 5 + public void createTenEmployer(Employer[] employers){ + System.out.println("Tare 5. Escribir un programa que cree 10 empleados y muestre todas sus propiedades."); int idBuscado = 9; double subidaSalario = 100; @@ -130,14 +120,5 @@ public void createTenEmployer(){ } } - - - - } - - - - - } diff --git a/src/employer/Employer.java b/src/employer/Employer.java index 0addd1d..842ab13 100644 --- a/src/employer/Employer.java +++ b/src/employer/Employer.java @@ -1,3 +1,4 @@ +//Tarea 3 package employer; public class Employer { @@ -8,11 +9,11 @@ public class Employer { private int age; private double salary; private int experience; - private String post; + private String job; private final int ID; //Constructor - public Employer(String name, int age, double salary, int ID){ + public Employer(String name, int age, double salary, int ID){ this.name = name; this.age = age; this.salary =salary; @@ -35,8 +36,8 @@ public int getExperience(){ return experience; } - public String getPost(){ - return post; + public String getJob(){ + return job; } public int getId(){ diff --git a/src/employer/Intern.java b/src/employer/Intern.java index 8cabd2b..9ea6584 100644 --- a/src/employer/Intern.java +++ b/src/employer/Intern.java @@ -1,3 +1,4 @@ +//Tarea 4. package employer; public class Intern extends Employer { From b11cbf84ba8a5d823b4013eed0cf67d1b3b93ead Mon Sep 17 00:00:00 2001 From: Dani <148881254+daniorta@users.noreply.github.com> Date: Thu, 27 Mar 2025 17:54:50 +0100 Subject: [PATCH 3/3] done end --- out/production/lab-java-basics-es/Main.class | Bin 3838 -> 4138 bytes .../employer/Employer.class | Bin 1320 -> 2060 bytes .../lab-java-basics-es/employer/Intern.class | Bin 895 -> 970 bytes src/Main.java | 25 +++++++++--------- src/employer/Employer.java | 6 ++++- src/employer/Intern.java | 8 +++--- 6 files changed, 22 insertions(+), 17 deletions(-) diff --git a/out/production/lab-java-basics-es/Main.class b/out/production/lab-java-basics-es/Main.class index 8dfe884eac36c2def0687c442e80a5dd4aad5678..96e7dc2451b3596d81383dbb55cd7370ab9cdb65 100644 GIT binary patch delta 2302 zcmZWqYj6`)6#j0L>~6v$%aWD`QX0xb`k*aE5n3KCR3Lo-5?+N0F3nO3X;QZ-P#y*a z1wlnz6i`G&6u}3A7&ItPp9nrc{f*8zBQyT;hvP5^o_m{uj-Bc0-tV68-0wW@?aiFS z0nde-sZ#)|@Y8nB0>6U07~GSsSTr6mqhSwZXewOj%}{7pIr}7n)xo-D#tNe(Vnmxu zLUF4l+FTLLpQE4;gR`c?h)R_|@1THyg1!t|$c(nctU$F9Hv)@|c2j|m!8OASTQTyS zy}rvchsZN$PMxYCmq7{{(XeGml~+%vw+Auwnqo#xD`7+e^+wcaHZ2817~~oXzr?i2 z_eCCw4$WuiS!WvIz(k{IIZr}CA)QDpGa^;~@=V&TghJMI2yG#=sl#fCcgh$+pxN3M ziFKM*NiZ5Wt*C;Lq^RDonquuzW#Up@ntvbVmgbAxCQ@!5ltNQbP9?00n9I^xT-lta zjAu|o9c^tfD;}t!8Y-wHVKuS#^M|C$@4Jgu&5%`Xt}r99wpNqcz&%4vR!du4!DJ#x z!FFRYPvvrVDm8af>CRb39aXg6Xo-4I3kNsTRm{Kxb|=eKY7tT~ix&G>Us}vjF&Fdf z)2y_|d@PXBsNz8^w6C*~zK0l;S%zgAff2g0cfE>7xr;k=#N%`jK_MezSe=4dt<#`x;*vJozdDKw zOR0k{!!1o_pw;N4I}kP_0mHJ4&hh|L z@Cie|?rk&r@9lutKW%T6%Gp`_w3N@z+t;Kr_L=RM3)vU;RC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c_KNjFC>qJFR(aTB?vev6V+kg5u&KL(3i8-y^-%p)v4dS^?8P4cghEwV zRFSnB>eP~GpEUywVh3VQs$n8y!WX*i5eU&-xM?$r#Mf=*L3#uVO4Cv}wa^su4vU@` zDW&5z3a}raVSiwC;N+)R`wAOVxUZa{L+<2|30@$>%^glE(YM^kRgS&CeLU1kG%u88 Mo{O&0B2UA?FXJyWH2?qr diff --git a/src/Main.java b/src/Main.java index 686c2f5..f1d9014 100644 --- a/src/Main.java +++ b/src/Main.java @@ -14,18 +14,18 @@ public static void main( String[] args){ //Creación de employers para tareas 3, 4, 5. Employer [] employers = new Employer[10]; - employers[0] = new Employer("María", 24, 32700, 0); - employers[1] = new Employer("Juan", 35, 36000, 1); - employers[2] = new Employer("Pedro", 22, 35500, 2 ); - employers[3] = new Employer("Sandra", 43, 34300, 3 ); - employers[4] = new Employer("Jenifer", 33, 34000, 4 ); - employers[5] = new Employer("Manel", 45, 38000, 5 ); + employers[0] = new Employer("María", 24, 32700, 6 , "Front end" , 0); + employers[1] = new Employer("Juan", 35, 36000, 17, "Senior Data base" , 1); + employers[2] = new Employer("Pedro", 22, 35500,4 , "RRHH" ,2 ); + employers[3] = new Employer("Sandra", 43, 34300, 25 , "General Manager" ,3 ); + employers[4] = new Employer("Jenifer", 33, 34000, 12 , "Lead Back end" ,4 ); + employers[5] = new Employer("Manel", 45, 38000, 2 , "Junior Security" ,5 ); //creación de Intern - employers[6] = new Intern("Marcos", 18, 15000 , 6); - employers[7] = new Intern("Alejandra", 20, 20000 , 7); - employers[8] = new Intern("José", 31, 18000 , 8); - employers[9] = new Intern("Isabel", 22, 19000 , 9); + employers[6] = new Intern("Marcos", 18, 15000, 2 , "Junior Data Base" ,6); + employers[7] = new Intern("Alejandra", 20, 20000 , 2 , "Support Java",7 ); + employers[8] = new Intern("José", 31, 18000 , 5 , "Development JavaScript" ,8); + employers[9] = new Intern("Isabel", 22, 19000 , 3, "Junior Back end", 9); Main main = new Main(); @@ -94,10 +94,11 @@ public void createTenEmployer(Employer[] employers){ System.out.println("Tare 5. Escribir un programa que cree 10 empleados y muestre todas sus propiedades."); int idBuscado = 9; - double subidaSalario = 100; + double subidaSalario = 50100; //Mostrar por consola empleados y sus datos System.out.println("Trabajadores de la empresa IT S.l.\n"); + for(Employer employer : employers){ System.out.println("ID: " + employer.getId() + " - " + employer.getName() + " de " + employer.getAge() + " años, salario -> " + employer.getSalary() + "€."); @@ -108,7 +109,7 @@ public void createTenEmployer(Employer[] employers){ double nuevoSalario = intern.getSalary() + subidaSalario; if (nuevoSalario > intern.getMAXSALARY()){ - System.out.println("\nEl salario actual de " + employer.getName() + " es de " + employer.getSalary() + "€," + " es el máximo permitido para un Intern." ); + System.out.println("\nEl salario actual de " + employer.getName() + " es de " + ((Intern) employer).getMAXSALARY() + "€," + " es el máximo permitido para un Intern." ); }else{ //Si el salario no supera los 20000€ anuel, dejara sumar la cantidad sin superar diff --git a/src/employer/Employer.java b/src/employer/Employer.java index 842ab13..16e373e 100644 --- a/src/employer/Employer.java +++ b/src/employer/Employer.java @@ -13,10 +13,12 @@ public class Employer { private final int ID; //Constructor - public Employer(String name, int age, double salary, int ID){ + public Employer(String name, int age, double salary, int experience, String job, int ID){ this.name = name; this.age = age; this.salary =salary; + this.experience = experience; + this.job = job; this.ID = ID; } //getter @@ -33,10 +35,12 @@ public double getSalary(){ } public int getExperience(){ + System.out.println("Con " + experience + " años de experiencia."); return experience; } public String getJob(){ + System.out.println("Departamento de " + job); return job; } diff --git a/src/employer/Intern.java b/src/employer/Intern.java index 9ea6584..a992f5b 100644 --- a/src/employer/Intern.java +++ b/src/employer/Intern.java @@ -7,13 +7,12 @@ public class Intern extends Employer { private final int MAXSALARY = 20000; //constructor - public Intern(String name, int age, double salary, int ID){ - super(name, age, salary, ID); + public Intern(String name, int age, double salary, int experience, String job, int ID){ + super(name, age, salary, experience, job, ID); if(salary > MAXSALARY){ throw new IllegalArgumentException("El salario no puede ser mayor que " + MAXSALARY); } - } public int getMAXSALARY() { @@ -25,7 +24,8 @@ public int getMAXSALARY() { @Override public void setSalary(double salary){ if(salary > MAXSALARY){ - throw new IllegalArgumentException("El salario no puede ser mayor que " + MAXSALARY); + getMAXSALARY(); + //throw new IllegalArgumentException("El salario no puede ser mayor que " + MAXSALARY); }else { //Si el valor de salario de un intern no supera el maximo, se puede actualizar, simepre que no supere el MAXSalary super.setSalary(salary);