From 1fd7e8e13e081311ef160fc1f25291a40bc25ab2 Mon Sep 17 00:00:00 2001 From: LirSA6CW Date: Mon, 18 May 2026 11:34:18 +0200 Subject: [PATCH 1/5] Lab Java Basics completed --- .idea/.gitignore | 10 ++++ .idea/lab-java-basics.iml | 11 ++++ .idea/misc.xml | 6 ++ .idea/modules.xml | 8 +++ .idea/vcs.xml | 6 ++ Notes.org | 12 ++++ out/production/lab-java-basics/A01_Main.class | Bin 0 -> 1269 bytes .../lab-java-basics/A02_ArrayUtils.class | Bin 0 -> 1433 bytes .../lab-java-basics/A03_Employee.class | Bin 0 -> 1902 bytes .../lab-java-basics/A04_Intern.class | Bin 0 -> 1658 bytes .../lab-java-basics/A05_EmployeeList.class | Bin 0 -> 1299 bytes src/A01_Main.java | 18 ++++++ src/A02_ArrayUtils.java | 33 +++++++++++ src/A03_Employee.java | 56 ++++++++++++++++++ src/A04_Intern.java | 30 ++++++++++ src/A05_EmployeeList.java | 21 +++++++ 16 files changed, 211 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/lab-java-basics.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 Notes.org create mode 100644 out/production/lab-java-basics/A01_Main.class create mode 100644 out/production/lab-java-basics/A02_ArrayUtils.class create mode 100644 out/production/lab-java-basics/A03_Employee.class create mode 100644 out/production/lab-java-basics/A04_Intern.class create mode 100644 out/production/lab-java-basics/A05_EmployeeList.class create mode 100644 src/A01_Main.java create mode 100644 src/A02_ArrayUtils.java create mode 100644 src/A03_Employee.java create mode 100644 src/A04_Intern.java create mode 100644 src/A05_EmployeeList.java diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..30cf57e --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/lab-java-basics.iml b/.idea/lab-java-basics.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/.idea/lab-java-basics.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..0280eb4 --- /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..505d07d --- /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/Notes.org b/Notes.org new file mode 100644 index 0000000..d6e9e6d --- /dev/null +++ b/Notes.org @@ -0,0 +1,12 @@ +* Notes + + +# Personal notes of the task (Spanish) + +** Notas de la tarea + +- Versionado de los forks con objeto, alcance, versión y fechas + + + + diff --git a/out/production/lab-java-basics/A01_Main.class b/out/production/lab-java-basics/A01_Main.class new file mode 100644 index 0000000000000000000000000000000000000000..21e28a4cc00e43660c3f6c877579ad385d09e90a GIT binary patch literal 1269 zcmaJ>+fEZf82$#@ZmA0`ML;}2L68=d0*VI;Xem@m3Nq|c4ec5NI)Vr>#E$qWPaE7kNSAhx zL`^Y-7NjZF5<`13Rp~$&9U3A!?m)k$UT!){)Je-aA*0@+2PCcZ2V0t|tZc#SnJ~H- zx)v7~6IQ%zM!&g}!T>A6Kr-7!6% zByZa;5OCQ#v1=kP-3U4_olLonrHNU#EafPhH#USiwDz1Z7D?->Ir9k?4dHDB?~v87 z?6xPzFnTqY(mb_}McVJZ-?2QeDa&p$d}*DI3q{}08aMZ-52HoPIzDM+Zf4oSxn{W4 zY=~RbTMOaeluYZCTtMWg`DLjDRah^Wrm%AccN{?t%rlJL$mzCFHLNiV{$G_Ysh<~y z@suvK`?Y~a4k22nh)UDWXb(>O1pDTR)3mx`&_7M9?kivhvqW{^IbIOQHU5f#2f7&x z{fboEL#1jUP^t!FTB#Zema1B;qf`xRrQ&yJ@y;KJ(mr{H-g7(vd@?>nJMo5Hl`%S> zVf-qJ5qebIScafsoX#)laap2xmJ!7|Jr5h`_9E=_qre<#fV9(ih1V2gJKhl8hIwRY U4-;pJ{spWM6`|8A-lKqle|8%&uK)l5 literal 0 HcmV?d00001 diff --git a/out/production/lab-java-basics/A02_ArrayUtils.class b/out/production/lab-java-basics/A02_ArrayUtils.class new file mode 100644 index 0000000000000000000000000000000000000000..8670738a814736a6fdc01414ce3f1e95bd336625 GIT binary patch literal 1433 zcmaJ>&u<$=6#gb_d+n|5Bo1zxI!QxGA$B1S0SeT1OA-{-lG`9TghLK!Vo#E7>|JYj zQpkx5e*`zAfYb{YIDnKx{{ZfA=ilJa@Qv4PY$d|0nfK<+`|*AAX8h;Nvljq1vF>0D zmW@~%aU=vLp2}yk+>zcvd28>fYH5K))%9HcK)_lm?$}5QOkOzEJ*^H@V10LfexAZL zq-|u<$YOjXRr4g&s>=-iF%#w+{dm_ee-XHzZt6hEZY4)NlWF8IB{1EUM{2|OT2g=I z>O*RwmYxn7yHqbm;eCvZb-ja%gFLR=m`>vcW(20L$S+{`Otp?@l3Y$v+{uB=Y|IK| z*H%`)UJC+w@}+h=tQyQ~g+ zP1(|ZK(;>&w`1TKRevPCHt8)keE;aUSGnA^A!JSK-u7YagGlBX4cje29c;QVH_zKO>;vM8W3 zOMgK8N@Wc5oXs{kZgEaW4p?9kAcfm_ixw076TM@UDC7Cdn~BX*gQ!qiNj=-lxn` VyGO>W{rN*wX>+));UU&A^B)~NK*az6 literal 0 HcmV?d00001 diff --git a/out/production/lab-java-basics/A03_Employee.class b/out/production/lab-java-basics/A03_Employee.class new file mode 100644 index 0000000000000000000000000000000000000000..29e59af3280a02d09d1a80830ac4895e7ce87d3c GIT binary patch literal 1902 zcmbW1TTj$L6vzJq%iiq5aurY%6l7U0i-I>0P+5t_RUa_;;DZ^K5enUQ(+(!YnD{aL z7HT3f@xc$^hccei7Pc(K7}K;fbLPxBzd4uw`u*c4fHkaS(Sp_#5(e6k6v*$&cd}$j zd%N^vb5~WhK=Phxn|fKGwJ@=fK^mD9vIfq<5HKFh&b@h5t6R>2QUaN`rt9hFvPSc+ zO2gE;c1?SGkq@^U=-`uSO9q-O>@?8D!t9o+OIO#Fty$b-pcj2a;7Lom2LhtpMb!NU z1~4daz9#q7s$*BBer4(%nt58<+7ozMIPLsjB;|?IS^^9IZEZs!vFdD5G&(A#t)B1K zHkJEQZd!hPoT{`oq-*jz6ejeJN&M}VXj~U5&f7|_HDcRShy^vg6I#77+!KU!j*L~p z=+lZ0HC8#=D<3C8AV<5=b%yrW!)#DJlqu(=aU@9;%IqMmogm|s(RF9vt*SMXuiP2E z)eM&h72HF|(Vli?{h87`&X$+P4S|)TntFd+QA^`ud}{cpYJydxT!M8_Crjc(M-uZ{ z+{CREZgaKV5g2WhqiMf$_Eafg3<_vXR<*+=_9+^)P%$8TEbT2zd7~A_+1sx#p01RL zWE=$mtdYoo0+_C;hP3n)-l{97{=%;akz87ir5v@qlI9U7+QJg$PsyKCs zTygpk`C@vqP-oYo^IZhMp|i$x}Dk9zYJ4Xn&sUvesn`)5tR>5&n!>m~W7O z8RU~^%#)z~5nKsrN;I;5Tk#uGUue<-cAWHudEZH3uq|{Va22EB;bqch7fJsb4Q&2b z0zCxR>s#mxw2m>8Atogz79`gU(jNDm=VQ8RwiQi{mFMDoD)~flQwP z!ZpGm)5j6HPudL9$2CH4j@~@I-9K<1Xb#c!2w7j4@>b0F{3XoNm?mp;^j^nZT5)$Q J;2xGS@COa+YSaJ# literal 0 HcmV?d00001 diff --git a/out/production/lab-java-basics/A04_Intern.class b/out/production/lab-java-basics/A04_Intern.class new file mode 100644 index 0000000000000000000000000000000000000000..896cf79135b995b1f66582b1eb4b104ccaeddc4f GIT binary patch literal 1658 zcma)6U2hvj6g^`buj6jw;^xypyM>e_ZkmKPe8o+vYd191Nh2JkAReNLGbG!rcdgxV z)d=yrf-xif$N`|2+MYuL&og|vl? zjkk~$u&YaVb|1DoUU00GK=!WdyZWBM%53AAd@dI~=^rdMb?EvBmH#tRpWDeJhan4j z8<$`U7c6x#u658u((B1n$(nRS8^B^SbZu(pF~%j1kQ zDy&e(LH&T9KB%jszZGK!1?g;7I)f{ygK2>NmU1YNPt~ zw*sP0x~EV(((7{HnOd;VuF!COwb^a&sc>8Fc^oM=f|m4lWat{dH<;0fE;-tbe(6-W z(eL{@76+LLQ_>|JP8A`HaVi&KVyk zM&t{~ybMw$gME*ZBwOC*N`~ur`2<(l-eg4v7Vm8g)$7jfo&RN3b^S7&>Guju7zJ;nx}VCp}I2ad)7 literal 0 HcmV?d00001 diff --git a/out/production/lab-java-basics/A05_EmployeeList.class b/out/production/lab-java-basics/A05_EmployeeList.class new file mode 100644 index 0000000000000000000000000000000000000000..c81e59c21d6e0735dd1ba8f736f7fbb9d63b839c GIT binary patch literal 1299 zcma)5OK($06#mA(zW3UgBn(bcDgv}n2noeefVPTx*m*cF2SQ9kP1>eoGfgJBzBjtQ zPQ|W^{sevj8`gBuNT9N=kPu>5)KwQ12&#(i+D+-1v3X^MeCK>;&YZdT-|f2q ziU?AOA@0CRBLSPCYfWs5tS9`H?1k!@tVIm=Y2~ZvEJM8i=%NFcAzc_cu{=@V@Pcbn zx=1l33ZAObGEK{JT}7)dIv93L_$$hnGF1MGoqzfpDFP`t;96}r!$^PWwO%>WyxhAW z<3|@=bW=v7LDfYsiOvMRY`ECNken0Yx{QqE;|(L}qK}R-CPFVD&VE`?im;}Ho&T%Y zCLE*~<4X9##YYskq|bGPAvU#O=l}S(O&TQ2#3oTbrVw*Y&y%5xEQ3>2zVK_(&i~zO zs18mrqzXePm#6(mhQ5na6u%e>f8E8Wv>XkC?|eJ|@VcR=FbwYEG#MsCq3cN1wl6EM z5fJIuwYK~ygEeJR9H&HPRo%`%U;17fT}+W}dQ*_n47twBC=533{GSVL*Ygy5rs*ll zeV&#JL8GDU{QZ(KCvgd%J6KHPGQN1L1O6W*c-mEN~OD_T_zZQC9w$IxLic-geXVicu=n6EpTSV`ILY9e$l zZMW_$N20bqCpL_pgEhM3a?lKGvZ!=Y-P?7K>tf&oEYl;?zZj_auxS*u%hJqfP7G{; z-7@AXjoJ+QYBZ)>1YCurT@v5EbY?|*ND0E8bftcVQ;FZ9fhYM6zB7Z)E$k{+ECXeD z4}UL%_YIUV&|bbzvkn-@HqeLs5I>wjzkwVB4e(?9cm_iTa_?Zc!cX!~wBu)67%5k} z$dj-fKcnNHYhf+d0w2?^6UMcRd?~d_KCOLcTUgTg&hZOc^`iEj9ViXnJrh6MxAz8m z2K$CbtRGR{WBr864{>($#WP)>ICOn_%(*T6f?aq7j^Am1jEt#Q50&^4J%<&nLNg9P eK|h~$`Z9>UzynwgJo+;#@;~UM`qs%7ga1FTI~)!G literal 0 HcmV?d00001 diff --git a/src/A01_Main.java b/src/A01_Main.java new file mode 100644 index 0000000..40a66e9 --- /dev/null +++ b/src/A01_Main.java @@ -0,0 +1,18 @@ +public class A01_Main { + + public static void main(String[] args) { + + // Task 1: difference between largest and smallest value + int[] numbers = {3, 1, 7, 2, 9, 4}; + System.out.println("=== Task 1 ==="); + System.out.println("Difference: " + A02_ArrayUtils.getDifference(numbers)); + + // Task 2: smallest and second smallest + System.out.println("=== Task 2 ==="); + A02_ArrayUtils.findTwoSmallest(numbers); + + // Task 5: create 10 employees and print all properties + System.out.println("=== Task 5 ==="); + A05_EmployeeList.printEmployees(); + } +} \ No newline at end of file diff --git a/src/A02_ArrayUtils.java b/src/A02_ArrayUtils.java new file mode 100644 index 0000000..e8697f8 --- /dev/null +++ b/src/A02_ArrayUtils.java @@ -0,0 +1,33 @@ +public class A02_ArrayUtils { + + // Task 1: difference between largest and smallest value in an array + public static int getDifference(int[] array) { + int max = array[0]; + int min = array[0]; + + for (int i = 1; i < array.length; i++) { + if (array[i] > max) max = array[i]; + if (array[i] < min) min = array[i]; + } + + return max - min; + } + + // Task 2: find smallest and second smallest elements + public static void findTwoSmallest(int[] array) { + int smallest = Integer.MAX_VALUE; + int secondSmallest = Integer.MAX_VALUE; + + for (int i = 0; i < array.length; i++) { + if (array[i] < smallest) { + secondSmallest = smallest; + smallest = array[i]; + } else if (array[i] < secondSmallest && array[i] != smallest) { + secondSmallest = array[i]; + } + } + + System.out.println("Smallest: " + smallest); + System.out.println("Second smallest: " + secondSmallest); + } +} diff --git a/src/A03_Employee.java b/src/A03_Employee.java new file mode 100644 index 0000000..f8c1d48 --- /dev/null +++ b/src/A03_Employee.java @@ -0,0 +1,56 @@ +public class A03_Employee { + + private String firstName; + private String lastName; + private String department; + private double salary; + + public A03_Employee(String firstName, String lastName, String department, double salary) { + this.firstName = firstName; + this.lastName = lastName; + this.department = department; + this.salary = salary; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getDepartment() { + return department; + } + + public void setDepartment(String department) { + this.department = department; + } + + public double getSalary() { + return salary; + } + + public void setSalary(double salary) { + this.salary = salary; + } + + @Override + public String toString() { + return "Employee{" + + "firstName='" + firstName + '\'' + + ", lastName='" + lastName + '\'' + + ", department='" + department + '\'' + + ", salary=" + salary + + '}'; + } +} \ No newline at end of file diff --git a/src/A04_Intern.java b/src/A04_Intern.java new file mode 100644 index 0000000..404f445 --- /dev/null +++ b/src/A04_Intern.java @@ -0,0 +1,30 @@ +public class A04_Intern extends A03_Employee { + + public static final double MAX_SALARY = 20000; + + public A04_Intern(String firstName, String lastName, String department, double salary) { + super(firstName, lastName, department, 0); + setSalary(salary); + } + + @Override + public void setSalary(double salary) { + if (salary > MAX_SALARY) { + System.out.println("Warning: Intern salary cannot exceed " + MAX_SALARY + ". Setting to max."); + super.setSalary(MAX_SALARY); + } else { + super.setSalary(salary); + } + } + + @Override + public String toString() { + return "Intern{" + + "firstName='" + getFirstName() + '\'' + + ", lastName='" + getLastName() + '\'' + + ", department='" + getDepartment() + '\'' + + ", salary=" + getSalary() + + ", maxSalary=" + MAX_SALARY + + '}'; + } +} \ No newline at end of file diff --git a/src/A05_EmployeeList.java b/src/A05_EmployeeList.java new file mode 100644 index 0000000..a1bdbd7 --- /dev/null +++ b/src/A05_EmployeeList.java @@ -0,0 +1,21 @@ +public class A05_EmployeeList { + + public static void printEmployees() { + A03_Employee[] employees = { + new A03_Employee("Alice", "Smith", "Engineering", 55000), + new A03_Employee("Bob", "Jones", "Marketing", 48000), + new A03_Employee("Carlos", "Garcia", "Engineering", 62000), + new A03_Employee("Diana", "Lee", "HR", 45000), + new A03_Employee("Eva", "Muller", "Finance", 70000), + new A04_Intern("Frank", "Brown", "Engineering", 18000), + new A04_Intern("Grace", "Wilson", "Marketing", 25000), + new A03_Employee("Hana", "Kim", "Finance", 67000), + new A03_Employee("Ivan", "Petrov", "Engineering", 58000), + new A04_Intern("Julia", "Rossi", "HR", 15000) + }; + + for (A03_Employee e : employees) { + System.out.println(e); + } + } +} From e5afbe6eda96cb53bee43bfba1dd39be4e08c549 Mon Sep 17 00:00:00 2001 From: LirSA6CW Date: Mon, 18 May 2026 11:35:53 +0200 Subject: [PATCH 2/5] Add gitignore --- .gitignore | Bin 0 -> 30 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..cb74bf67c6408f910da7ad72626748880977ab3d GIT binary patch literal 30 gcmezWFQ1{5p@c!7ftP`cL60GmA%!88ArZ<40C^Y%qW}N^ literal 0 HcmV?d00001 From 304b56fc447bb35ba3b3f18a9878d6c272c9c3f9 Mon Sep 17 00:00:00 2001 From: LirSA6CW Date: Mon, 18 May 2026 12:39:39 +0200 Subject: [PATCH 3/5] Add lab notes --- Notes.md | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ Notes.org | 12 ----- 2 files changed, 140 insertions(+), 12 deletions(-) create mode 100644 Notes.md delete mode 100644 Notes.org diff --git a/Notes.md b/Notes.md new file mode 100644 index 0000000..6efacaf --- /dev/null +++ b/Notes.md @@ -0,0 +1,140 @@ +# Lab Notes | Java Basics + +## Purpose + +Practice Java fundamentals through the implementation of array algorithms, class design with inheritance and data validation, applying object-oriented programming principles. + +## Scope + +- Array search algorithms (maximum, minimum, second minimum) +- `Employee` class design with encapsulation (getters/setters) +- Inheritance with `Intern` class and salary limit validation +- Object instantiation and display in a collection + +--- + +## Timeline + +- **Date:** 2026-05-18 +- **Start:** 11:14 +- **End:** 13:14 +- **Total:** 120 min + +| Task | Estimated time | +|-------------------------------------|----------------| +| Setup (GitHub, IntelliJ, structure) | 35 min | +| T1 — getDifference | 10 min | +| T2 — findTwoSmallest | 15 min | +| T3 — Employee | 20 min | +| T4 — Intern | 25 min | +| T5 — EmployeeList | 15 min | +| **Total** | **120 min** | + +--- + +## Versioning + +### Index + +| Version | Date | Description | +|---------|------------|-----------------------------------------| +| v1.0.0 | 2026-05-18 | Initial submission. 5 tasks completed. | + +--- + +#### v1.0.0 + +### Feedback received + +- T1: Excellent. Solid and efficient implementation. +- T2: Excellent. Optimal solution using two variables and a single loop. +- T3: Fantastic. Well-structured class with a useful toString() method. +- T4: Well done. Correct inheritance and salary limit validated. +- T5: Excellent. Correct use of both employee types. + +--------------------------------------------------------- + +--------------------------------------------------------- + +--------------------------------------------------------- + +--------------------------------------------------------- + +--------------------------------------------------------- + +--------------------------------------------------------- + +--------------------------------------------------------- + +--------------------------------------------------------- + +--------------------------------------------------------- + +--------------------------------------------------------- + +--------------------------------------------------------- + +--------------------------------------------------------- + + +# Lab Notes | Fundamentos de Java + +## Objeto + +Practicar fundamentos de Java mediante la implementación de algoritmos con arrays, diseño de clases con herencia y validación de datos, aplicando programación orientada a objetos. + +## Alcance + +- Algoritmos de búsqueda en arrays (máximo, mínimo, segundo mínimo) +- Diseño de clase `Employee` con encapsulamiento (getters/setters) +- Herencia con clase `Intern` y validación de límite salarial +- Instanciación y visualización de objetos en colección + +--- + + + +## Temporalización + +- **Fecha:** 2026-05-18 +- **Inicio:** 11:14 +- **Fin:** 13:14 +- **Total:** 120 min + +| Tarea | Tiempo estimado | +|------------------------------------|-----------------| +| Setup (GitHub, IntelliJ, estructura) | 35 min | +| T1 — getDifference | 10 min | +| T2 — findTwoSmallest | 15 min | +| T3 — Employee | 20 min | +| T4 — Intern | 25 min | +| T5 — EmployeeList | 15 min | +| **Total** | **120 min** | + +--- + + +## Versionado + +### Índice + +| Versión | Fecha | Descripción | +|---------|------------|------------------------------------| +| v1.0.0 | 2026-05-18 | Entrega inicial. 5 tareas completadas. | + +--- + +#### v1.0.0 +### Feedback recibido + +- T1: Excelente. Implementación sólida y eficiente. +- T2: Excelente. Solución óptima con dos variables y un solo bucle. +- T3: Fantástico. Clase bien estructurada con toString() útil. +- T4: Bien hecho. Herencia correcta y límite salarial validado. +- T5: Excelente. Uso correcto de ambos tipos de empleados. + +--------------------------------------------------------- + +--------------------------------------------------------- + +--------------------------------------------------------- \ No newline at end of file diff --git a/Notes.org b/Notes.org deleted file mode 100644 index d6e9e6d..0000000 --- a/Notes.org +++ /dev/null @@ -1,12 +0,0 @@ -* Notes - - -# Personal notes of the task (Spanish) - -** Notas de la tarea - -- Versionado de los forks con objeto, alcance, versión y fechas - - - - From 66f0afe443bdaecedfd5bc205a91c17ed8384a95 Mon Sep 17 00:00:00 2001 From: LirSA6CW Date: Mon, 18 May 2026 12:51:01 +0200 Subject: [PATCH 4/5] Add comments to all classes --- out/production/lab-java-basics/A01_Main.class | Bin 1269 -> 1269 bytes .../lab-java-basics/A02_ArrayUtils.class | Bin 1433 -> 1433 bytes .../lab-java-basics/A03_Employee.class | Bin 1902 -> 1886 bytes .../lab-java-basics/A04_Intern.class | Bin 1658 -> 1658 bytes .../lab-java-basics/A05_EmployeeList.class | Bin 1299 -> 1299 bytes src/A01_Main.java | 10 ++-- src/A02_ArrayUtils.java | 25 ++++++++-- src/A03_Employee.java | 46 ++++++++---------- src/A04_Intern.java | 18 ++++++- src/A05_EmployeeList.java | 11 ++++- 10 files changed, 72 insertions(+), 38 deletions(-) diff --git a/out/production/lab-java-basics/A01_Main.class b/out/production/lab-java-basics/A01_Main.class index 21e28a4cc00e43660c3f6c877579ad385d09e90a..3a3771647a27f7938b325abe9274818e82c99fe6 100644 GIT binary patch delta 47 zcmey$`IU169}6SvWPX-bSuO^725ts*1|9}827U%R1_1^q24My-1`!5d2GPkISzG|p Co(HG^ delta 47 zcmey$`IU169}6SnWPX-bSvCfF26hH@1`Y-@25tsB1|9|{27U%F1_1_N2EoZ2SzG|m Cq6dTk diff --git a/out/production/lab-java-basics/A02_ArrayUtils.class b/out/production/lab-java-basics/A02_ArrayUtils.class index 8670738a814736a6fdc01414ce3f1e95bd336625..aed2eb9d40aa67a2f979c17914f058e5aea6c90d 100644 GIT binary patch delta 93 zcmbQqJ(GLGVP;0w$w!#eCHWXw82A}D7z7yv7=#$48H5?sfNUKGvB@qh+jZp`m>Cop s*cg-;_!yKKL>W{W#DVg14C+7?nhXX&aWe*81}6qR20sS<$r`MM0DFxK-~a#s delta 93 zcmbQqJ(GLGVP;0g$w!#eC0Q9*7}yv%fKY&elR=t+i$M*@)?whC?835LSBQa`K^Q16 n%D~4U1|-FSP=Y~@K@zA!iopOVVg}?nF~~FcF(^#dU@ZgySdj|$ diff --git a/out/production/lab-java-basics/A03_Employee.class b/out/production/lab-java-basics/A03_Employee.class index 29e59af3280a02d09d1a80830ac4895e7ce87d3c..7ace838ed6d8c284b5cb61042160c42c139e097a 100644 GIT binary patch delta 199 zcmaFIcaLvFD~l*U0}F!y11EzZ10RDBgD?UE?K*+$rrlq}=fp;U2#l#>B;)7Mo09A`m ze#olNC} GTLA!QXB~I| delta 221 zcmcb|_l|EvD~l)x0}BHu5OOi_F>o^oGw?7-GVo5G#gf7(F!?`=Jfq!Yc~)_5E(RtB z1_luZRtC|@wybWG|FMYasxhcAFfzyh#qEHyAbB<|?X3*F8-Xk)23a5p(Io@aB@5Ig zKKUlAKBEHARME+DY+TAHx&+X5sQ`7Uf_25Q=`(78ba87l=)i28yp9d#DjlFoU9if> MYz~ZulU3NQ0PV&gO#lD@ diff --git a/out/production/lab-java-basics/A04_Intern.class b/out/production/lab-java-basics/A04_Intern.class index 896cf79135b995b1f66582b1eb4b104ccaeddc4f..ba90af3ea7ffea5e5f1c64dfa957192f0c28cc14 100644 GIT binary patch delta 69 zcmeyx^NVMLAuA_80|$cu10RFnWGmKsK}jG_3dolRlCli)4Dyptu_lVDF)%WyGq5sf VFmN(xGVn5JF^Dp#O?F_j0sw{q35fsz delta 69 zcmeyx^NVMLAuA^v0|x^;10Ms&WGmKsK^`EFmq7r?mjaUV3__Dnu_lU&F)%WSGq5s9 UFmN(R0_CL`L>a^;JFr;+0C0B*%>V!Z diff --git a/out/production/lab-java-basics/A05_EmployeeList.class b/out/production/lab-java-basics/A05_EmployeeList.class index c81e59c21d6e0735dd1ba8f736f7fbb9d63b839c..22d64ab41de5b2578b46c0945d331a24abeeb841 100644 GIT binary patch delta 36 rcmbQtHJNL}B4$Rm&5N1k83nl*PB2I?++>hscnGAQGe}Rq%;Eq5vycg* delta 36 rcmbQtHJNL}B4$R$&5N1k83kDwPA~{E+++}9cnGAQGl)#S%;Eq5u~G?p diff --git a/src/A01_Main.java b/src/A01_Main.java index 40a66e9..61fb6c7 100644 --- a/src/A01_Main.java +++ b/src/A01_Main.java @@ -1,17 +1,21 @@ +/** + * A01_Main — Entry point of the Java Basics Lab. + * Orchestrates the execution of all tasks. + */ public class A01_Main { public static void main(String[] args) { - // Task 1: difference between largest and smallest value + // Task 1: Calculate the difference between the largest and smallest value in an array int[] numbers = {3, 1, 7, 2, 9, 4}; System.out.println("=== Task 1 ==="); System.out.println("Difference: " + A02_ArrayUtils.getDifference(numbers)); - // Task 2: smallest and second smallest + // Task 2: Find and print the smallest and second smallest elements System.out.println("=== Task 2 ==="); A02_ArrayUtils.findTwoSmallest(numbers); - // Task 5: create 10 employees and print all properties + // Task 5: Create 10 employees (including interns) and print all their properties System.out.println("=== Task 5 ==="); A05_EmployeeList.printEmployees(); } diff --git a/src/A02_ArrayUtils.java b/src/A02_ArrayUtils.java index e8697f8..0c84d22 100644 --- a/src/A02_ArrayUtils.java +++ b/src/A02_ArrayUtils.java @@ -1,28 +1,43 @@ +/** + * A02_ArrayUtils — Utility class for array operations. + * Contains methods for Tasks 1 and 2. + */ public class A02_ArrayUtils { - // Task 1: difference between largest and smallest value in an array + /** + * Task 1: Returns the difference between the largest and smallest value in an array. + * Uses a single loop to find max and min simultaneously. + * @param array integer array with length >= 1 + * @return difference between max and min values + */ public static int getDifference(int[] array) { int max = array[0]; int min = array[0]; for (int i = 1; i < array.length; i++) { - if (array[i] > max) max = array[i]; - if (array[i] < min) min = array[i]; + if (array[i] > max) max = array[i]; // update max if current value is greater + if (array[i] < min) min = array[i]; // update min if current value is smaller } return max - min; } - // Task 2: find smallest and second smallest elements + /** + * Task 2: Finds and prints the smallest and second smallest elements in an array. + * Uses two variables initialized to MAX_VALUE and a single loop. + * @param array integer array with length >= 2 + */ public static void findTwoSmallest(int[] array) { int smallest = Integer.MAX_VALUE; int secondSmallest = Integer.MAX_VALUE; for (int i = 0; i < array.length; i++) { if (array[i] < smallest) { + // New smallest found: shift current smallest to second position secondSmallest = smallest; smallest = array[i]; } else if (array[i] < secondSmallest && array[i] != smallest) { + // New second smallest found (must differ from smallest) secondSmallest = array[i]; } } @@ -30,4 +45,4 @@ public static void findTwoSmallest(int[] array) { System.out.println("Smallest: " + smallest); System.out.println("Second smallest: " + secondSmallest); } -} +} \ No newline at end of file diff --git a/src/A03_Employee.java b/src/A03_Employee.java index f8c1d48..a8cfbaa 100644 --- a/src/A03_Employee.java +++ b/src/A03_Employee.java @@ -1,3 +1,7 @@ +/** + * A03_Employee — Represents an employee of a company. + * Contains personal and professional properties with getters and setters. + */ public class A03_Employee { private String firstName; @@ -5,6 +9,9 @@ public class A03_Employee { private String department; private double salary; + /** + * Constructor with all properties. + */ public A03_Employee(String firstName, String lastName, String department, double salary) { this.firstName = firstName; this.lastName = lastName; @@ -12,38 +19,23 @@ public A03_Employee(String firstName, String lastName, String department, double this.salary = salary; } - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } + // --- Getters and Setters --- - public String getLastName() { - return lastName; - } + public String getFirstName() { return firstName; } + public void setFirstName(String firstName) { this.firstName = firstName; } - public void setLastName(String lastName) { - this.lastName = lastName; - } + public String getLastName() { return lastName; } + public void setLastName(String lastName) { this.lastName = lastName; } - public String getDepartment() { - return department; - } + public String getDepartment() { return department; } + public void setDepartment(String department) { this.department = department; } - public void setDepartment(String department) { - this.department = department; - } - - public double getSalary() { - return salary; - } - - public void setSalary(double salary) { - this.salary = salary; - } + public double getSalary() { return salary; } + public void setSalary(double salary) { this.salary = salary; } + /** + * Returns a readable string with all employee properties. + */ @Override public String toString() { return "Employee{" + diff --git a/src/A04_Intern.java b/src/A04_Intern.java index 404f445..03eed8a 100644 --- a/src/A04_Intern.java +++ b/src/A04_Intern.java @@ -1,12 +1,25 @@ +/** + * A04_Intern — Represents an intern. Extends A03_Employee. + * Interns have a maximum salary cap of 20000. + * If a higher salary is set, it is automatically capped and a warning is printed. + */ public class A04_Intern extends A03_Employee { + // Maximum salary allowed for any intern (constant) public static final double MAX_SALARY = 20000; + /** + * Constructor — validates salary on creation. + */ public A04_Intern(String firstName, String lastName, String department, double salary) { - super(firstName, lastName, department, 0); + super(firstName, lastName, department, 0); // initialize with 0, then validate setSalary(salary); } + /** + * Overrides setSalary to enforce the salary cap. + * If salary exceeds MAX_SALARY, it is set to MAX_SALARY and a warning is printed. + */ @Override public void setSalary(double salary) { if (salary > MAX_SALARY) { @@ -17,6 +30,9 @@ public void setSalary(double salary) { } } + /** + * Returns a readable string including the salary cap for debugging purposes. + */ @Override public String toString() { return "Intern{" + diff --git a/src/A05_EmployeeList.java b/src/A05_EmployeeList.java index a1bdbd7..c5fd1f8 100644 --- a/src/A05_EmployeeList.java +++ b/src/A05_EmployeeList.java @@ -1,6 +1,12 @@ +/** + * A05_EmployeeList — Creates a list of 10 employees (including interns) + * and prints all their properties. + * Demonstrates polymorphism: both Employee and Intern objects stored in the same array. + */ public class A05_EmployeeList { public static void printEmployees() { + // Array of 10 employees — mix of regular employees and interns A03_Employee[] employees = { new A03_Employee("Alice", "Smith", "Engineering", 55000), new A03_Employee("Bob", "Jones", "Marketing", 48000), @@ -8,14 +14,15 @@ public static void printEmployees() { new A03_Employee("Diana", "Lee", "HR", 45000), new A03_Employee("Eva", "Muller", "Finance", 70000), new A04_Intern("Frank", "Brown", "Engineering", 18000), - new A04_Intern("Grace", "Wilson", "Marketing", 25000), + new A04_Intern("Grace", "Wilson", "Marketing", 25000), // exceeds cap → set to 20000 new A03_Employee("Hana", "Kim", "Finance", 67000), new A03_Employee("Ivan", "Petrov", "Engineering", 58000), new A04_Intern("Julia", "Rossi", "HR", 15000) }; + // Print all properties using each class's toString() method for (A03_Employee e : employees) { System.out.println(e); } } -} +} \ No newline at end of file From 35c81d9e94dbf7b5ef1d7ed28615f790fcdfe80c Mon Sep 17 00:00:00 2001 From: LirSA6CW Date: Mon, 18 May 2026 13:07:28 +0200 Subject: [PATCH 5/5] Update notes v1.1.0 --- Notes.md | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/Notes.md b/Notes.md index 6efacaf..7fb3845 100644 --- a/Notes.md +++ b/Notes.md @@ -36,9 +36,10 @@ Practice Java fundamentals through the implementation of array algorithms, class ### Index -| Version | Date | Description | -|---------|------------|-----------------------------------------| -| v1.0.0 | 2026-05-18 | Initial submission. 5 tasks completed. | +| Version | Date | Description | +|---------|------------|------------------------------------------| +| v1.0.0 | 2026-05-18 | Initial submission. 5 tasks completed. | +| v1.1.0 | 2026-05-18 | Comments added to all classes. | --- @@ -52,6 +53,18 @@ Practice Java fundamentals through the implementation of array algorithms, class - T4: Well done. Correct inheritance and salary limit validated. - T5: Excellent. Correct use of both employee types. +--- + +#### v1.1.0 + +### Feedback received + +- T1: Excellent. Efficient implementation using a single loop for both max and min. +- T2: Excellent. Impeccable logic handling equal or similar values. +- T3: Fantastic. Well-structured class with clean encapsulation and readable toString(). +- T4: Well done. Correct inheritance, salary cap enforced with informative warning. +- T5: Excellent. Polymorphism demonstrated with both Employee and Intern types. Great attention to detail. + --------------------------------------------------------- --------------------------------------------------------- @@ -92,8 +105,6 @@ Practicar fundamentos de Java mediante la implementación de algoritmos con arra --- - - ## Temporalización - **Fecha:** 2026-05-18 @@ -113,18 +124,19 @@ Practicar fundamentos de Java mediante la implementación de algoritmos con arra --- - ## Versionado ### Índice -| Versión | Fecha | Descripción | -|---------|------------|------------------------------------| -| v1.0.0 | 2026-05-18 | Entrega inicial. 5 tareas completadas. | +| Versión | Fecha | Descripción | +|---------|------------|------------------------------------------| +| v1.0.0 | 2026-05-18 | Entrega inicial. 5 tareas completadas. | +| v1.1.0 | 2026-05-18 | Comentarios añadidos a todas las clases. | --- #### v1.0.0 + ### Feedback recibido - T1: Excelente. Implementación sólida y eficiente. @@ -133,6 +145,18 @@ Practicar fundamentos de Java mediante la implementación de algoritmos con arra - T4: Bien hecho. Herencia correcta y límite salarial validado. - T5: Excelente. Uso correcto de ambos tipos de empleados. +--- + +#### v1.1.0 + +### Feedback recibido + +- T1: Excelente. Implementación eficiente con un solo bucle para máximo y mínimo. +- T2: Excelente. Lógica impecable que maneja valores iguales o similares. +- T3: Fantástico. Clase bien estructurada con encapsulamiento limpio y toString() legible. +- T4: Bien hecho. Herencia correcta, límite salarial aplicado con advertencia informativa. +- T5: Excelente. Polimorfismo demostrado con ambos tipos de empleados. Gran atención al detalle. + --------------------------------------------------------- ---------------------------------------------------------