From a9c3f748c59f20cae6dc437652a68116a4d28bde Mon Sep 17 00:00:00 2001 From: Enger Duran Date: Fri, 3 Apr 2026 22:35:40 +0200 Subject: [PATCH] Laboratorio finalizado java basics --- .idea/.gitignore | 10 +++ .idea/lab-basics-java.iml | 11 +++ .idea/misc.xml | 6 ++ .idea/modules.xml | 8 ++ .idea/vcs.xml | 6 ++ out/production/lab-basics-java/Employee.class | Bin 0 -> 1803 bytes out/production/lab-basics-java/Intern.class | Bin 0 -> 743 bytes out/production/lab-basics-java/Main.class | Bin 0 -> 2850 bytes src/Employee.java | 55 +++++++++++++ src/Intern.java | 16 ++++ src/Main.java | 73 ++++++++++++++++++ 11 files changed, 185 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/lab-basics-java.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-basics-java/Employee.class create mode 100644 out/production/lab-basics-java/Intern.class create mode 100644 out/production/lab-basics-java/Main.class create mode 100644 src/Employee.java create mode 100644 src/Intern.java create mode 100644 src/Main.java diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..ab1f416 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/lab-basics-java.iml b/.idea/lab-basics-java.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/.idea/lab-basics-java.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..f5bd2df --- /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..87dec2e --- /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-basics-java/Employee.class b/out/production/lab-basics-java/Employee.class new file mode 100644 index 0000000000000000000000000000000000000000..6e6da164f056c1af63c9454cf61b08e0b436804d GIT binary patch literal 1803 zcmaKs+in|G6o&t8JLAMmo06tEw{=O1?TM+&`QRqBwG(P&%0;Sh!PSnv50D$HG6T-zt9IBXXe^LM|=Ca@5(rx%tePTV;9;3+w1hbm-x=?v}iU*iP`hzi7XZcbeO)f zGw_vbn@naDBuQa}z2LOpF}tpyTpL7tAlYM$JPm>CT zYEja#RZ^vDkygt@;_#OGan{0@1w6)+Jf4cr4TX)%x^Vqh!I7yYB#HIAx)TMG|DT5o zC>16Q&$Qq5Ot{ewf}_)u`gj(GX8yDA#o39OApd?ypB#kxu$}1^4efb*Ze*ASyXE_) z-|%!8nlO)Dh5KXQGzm42X9{=zU&``Kz6}90tivHRtvP-gcI97nuJ&Ui+SCVkNHx#+u>pI`_KCfgc5Pj41gCaP=HdzIOy^icPYW@NL zfE!oNaG(+gegIeg4`SAdP!Si;%-fy!X5RYe@9#eV9AV#qft(G~#U)q_`J-?VL`xwU ztcSkz)gy*RdpLT_-}7F;<-9jmu`lQS;bCWDBTv_cQi)hvkAHn2MxX!}B^w(q%BV0@ zE_5yvB|?T=lq!bWiqnsJ&xlYFt>9rlk19ib%mW@TJ#jV_VwQLzKl8&hbg+e*jk=2~ zXfSMM%>VW?*bB`TND^rOKXqrK_ieh^#x;gQBGgKX!EDn)49@Z3#jEjPG&p(5zz!Ko z2a!w^mukX;lw2_nq8Wwq$d}@28lH;yIX?{usg9y44<M^=*AKr@ULpT0Zhi#4k=j?#E4p7>g~xT4J<^)vF_7DYWn tj&=a*nPw4r`k5*y(KZ{jNjaORo+)~N=kcHw8SYV^38SgC_b4}T{|{z7j6?tc literal 0 HcmV?d00001 diff --git a/out/production/lab-basics-java/Main.class b/out/production/lab-basics-java/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..a86c138ef725c9617c6456827e67f713522f71c6 GIT binary patch literal 2850 zcmaJ@TXP&o75-X#nbBlzO~xx(vLt5}BwLqAB7r!uZpfDGux8~|kWpBh+jzGnjkPkLE94lEqLUIpMfYI3*D4 zA6PV?qgjKI!aYa{#OG|s71*~d!&zr(N&3<)N`XZGh3r7K8T-+q!A#*^SUX%VtOcR0 z(4$x50G}2z_Z+#x2H|PN5ZT0tYMhs+{rMq8&crge$xYLfZ`k&h5_* z)Tc)=bFSkqj~i%5hlWEbbfQb(z#jeuw5nRI%g;BhlX|qeEw?$nSYkc6mj)xfBye#=%a{A7f zq6KsuBQ|IIj-8zTW3GXXF$E{w&~qJH{^i96N}ct2yX;jQm++rnZNMjKJa5;^j!PH6 zD>cy5cTw8@b#t*ZteF!fue?O?w@*i=8qN~Tx}o%49rL`Ov)!63C#U~@DKaoHhanvw z5@0+vdvohiwTWJ0A~@&c8U3n_dAA7#)EecPeu3$*n&N+OaZ z+rY=~!N>6l4R#6_QKY}9D0Y~T&59kIl~<@Qi~YQsAyZhwGArGU;Pj^NZ7mX&o1<#& z(mSX^_1aNZ7A*QWOO}P>3EaEYY$`R&(vMx;*x0Zjkk-NKHizH#XR%w;bTQ+V*k&y` z$CYPmm5b6pXJ0H6v2tF~E-xyj`P=~G;fh0N$((A|an7zpP21LgVRxwwERs4C%u3B| z7Ot9N`^$83V2>HJtT+LqkiJKgrVCkW=*ys14yloVP|r#-)dMtWbo~sWdEY{47gy)(YD8JXRSnN@X@`osQGU2^tYTkLW3*u{Ierjsb@To} z7CpDL1sDrn%`eK+j>>AYO5BJNi;|r5yf6rTyE-Ss6|WTN_%;)hV`Vz^{m-#8G8oGU z9p5F}Q{_zM&b1&@l~2~>o!33SQ?FhT=;o_HF4x?Ww}(kf65liMef&Vf57jRCBZ1zn za&g?t-l`m}Z+G>L@w8oJ^{)xMynQ!o7}jHbzwMT|d-di#Z?#q(->v>OWXHsFRAUeG z?bWck0qu4%!!2`x-AS2JS=W{ROxX?s8ECjJ(6@`zUZHAuP2lkVH&q25@#3bSvrW`r zoSnqa8pj%+MtK#yCI)Xpyv~~@T;`}=12H_sF;zFf6|C{88K1NSeufK{K241>H3AxuIV|oBRd#b=|@NU>yeubl*l#;U?a7cK9}W z3vug+X{FJB6NBp*ej>sW)`Mm`jrVNFlGej!CXGk7W14l`98P0=JEmKc=2RN*+m4w@ z>x6lK8Z$dU%{pZsN#n5{pl)T&{xm+Y1sYz5@o$y!c$D!EBF%dZ8D_YTpT7rr zn0T0ng-NvFahQ-iFs#AC3(Vj(+OD(y|A0393kUHZvH!rF$LuA`$f=>p;_n zXh%ZBmoL!g|75#OjIw#*D{(q8Z=Pf)LRk|t&p9R4yt3Qk|rFxy*F)j}r=*LM=t rNwhU08pBImx(VOFH+fAngjY%XThaKPXnYwz<{N|PHT(oWMaTaD=>m~I literal 0 HcmV?d00001 diff --git a/src/Employee.java b/src/Employee.java new file mode 100644 index 0000000..4e4f721 --- /dev/null +++ b/src/Employee.java @@ -0,0 +1,55 @@ +public class Employee { + private int id; + private String name; + private int age; + private double salary; + + public Employee(int id, String name, int age, double salary) { + setId(id); + setName(name); + setAge(age); + setSalary(salary); + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + public double getSalary() { + return salary; + } + + public void setSalary(double salary) { + this.salary = salary; + } + + @Override + public String toString() { + return "Employee{" + + "id=" + id + + ", name='" + name + '\'' + + ", age=" + age + + ", salary=" + salary + + '}'; + } +} diff --git a/src/Intern.java b/src/Intern.java new file mode 100644 index 0000000..685b49b --- /dev/null +++ b/src/Intern.java @@ -0,0 +1,16 @@ +public class Intern extends Employee{ + private static final double MAX_SALARY = 20000.0; + + + public Intern(int id, String name, int age, double salary) { + super(id, name, age, salary); + } + + @Override + public void setSalary(double salary) { + if (salary > MAX_SALARY) { + System.out.println("Salary exceeds maximum"); + super.setSalary(MAX_SALARY); + } else {super.setSalary(salary);} + } +} diff --git a/src/Main.java b/src/Main.java new file mode 100644 index 0000000..50880b1 --- /dev/null +++ b/src/Main.java @@ -0,0 +1,73 @@ +import java.util.ArrayList; + +public class Main { + public static void main(String[] args) { + + //Creamos Array! + int[] misNumeros = {5, 2, 4, 6, 9, 10}; + + int resultado = getDifference(misNumeros); + System.out.println("La diferencia es: " + resultado); + findTwoSmallest(misNumeros); + + //ArrayList de empleados + ArrayList employees = new ArrayList<>(); + employees.add(new Employee(1, "JuanDeDios", 18, 500)); + employees.add(new Employee(2, "Pedro", 20, 10000)); + employees.add(new Employee(3, "Maria", 32, 15000)); + employees.add(new Employee(4, "Antonio", 45, 19000)); + employees.add(new Employee(5, "Palomino", 62, 17000)); + employees.add(new Employee(6, "Paulina", 34, 13000)); + employees.add(new Employee(7, "Paulino", 38, 20000)); + employees.add(new Employee(8, "Adolfo", 40, 11000)); + employees.add(new Intern (9, "Manuel", 39, 25000)); + employees.add(new Employee(10, "Francisco", 24, 17500)); + + System.out.println("Lista de empleados"); + + //Bucle para cada empleado + for(Employee emp: employees){ + System.out.println(emp); + } + + } + + //Creación Metod1 + public static int getDifference(int[] numbers) { + int max = numbers[0]; + int min = numbers[0]; + + //Bucle para recorrer array de números + for (int i = 0; i < numbers.length; i++) { + System.out.println(numbers[i]); + if (numbers[i] > max) { + max = numbers[i]; + } else if (numbers[i] < min) { + min = numbers[i]; + } + } + return max - min; + } + + //Metod2 + public static void findTwoSmallest(int[] numbers) { + int firstSmallest = Integer.MAX_VALUE; + int secondSmallest = Integer.MAX_VALUE; + + for (int i = 0; i < numbers.length; i++) { + if (numbers[i] < firstSmallest) { + secondSmallest = firstSmallest; + firstSmallest = numbers[i]; + } else if (numbers[i] < secondSmallest) { + secondSmallest = numbers[i]; + } + + } + System.out.println("El más pequeño es " + firstSmallest); + System.out.println("----------------"); + System.out.println("El segundo más pequeño es " + secondSmallest); + } + + + +}