From 9f751a6a947deed314c4942fa0ae5d8fdec44766 Mon Sep 17 00:00:00 2001
From: Motodies <39949690+Motodies@users.noreply.github.com>
Date: Sat, 29 Mar 2025 01:30:09 +0100
Subject: [PATCH 01/17] First commit
---
.idea/lab-java-basics.iml | 9 +++++++++
.idea/misc.xml | 6 ++++++
.idea/modules.xml | 8 ++++++++
.idea/vcs.xml | 6 ++++++
.idea/workspace.xml | 41 +++++++++++++++++++++++++++++++++++++++
5 files changed, 70 insertions(+)
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 .idea/workspace.xml
diff --git a/.idea/lab-java-basics.iml b/.idea/lab-java-basics.iml
new file mode 100644
index 0000000..d6ebd48
--- /dev/null
+++ b/.idea/lab-java-basics.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..31e1ebc
--- /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/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..56fc85d
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1743208028728
+
+
+ 1743208028728
+
+
+
+
\ No newline at end of file
From 16fe9a3e2b72f12c6160dcb8086e6248fd6ad0f7 Mon Sep 17 00:00:00 2001
From: Motodies <39949690+Motodies@users.noreply.github.com>
Date: Sat, 29 Mar 2025 01:31:31 +0100
Subject: [PATCH 02/17] First commit
---
.idea/lab-java-basics.iml | 4 ++-
src/Basics.java | 59 +++++++++++++++++++++++++++++++++++++++
src/Company.java | 21 ++++++++++++++
src/Employee.java | 42 ++++++++++++++++++++++++++++
src/Intern.java | 22 +++++++++++++++
5 files changed, 147 insertions(+), 1 deletion(-)
create mode 100644 src/Basics.java
create mode 100644 src/Company.java
create mode 100644 src/Employee.java
create mode 100644 src/Intern.java
diff --git a/.idea/lab-java-basics.iml b/.idea/lab-java-basics.iml
index d6ebd48..c90834f 100644
--- a/.idea/lab-java-basics.iml
+++ b/.idea/lab-java-basics.iml
@@ -2,7 +2,9 @@
-
+
+
+
diff --git a/src/Basics.java b/src/Basics.java
new file mode 100644
index 0000000..de6fe82
--- /dev/null
+++ b/src/Basics.java
@@ -0,0 +1,59 @@
+public class Basics {
+ public static void main(String[] args) {
+ diffLargestAndSmallest();
+ firstAndSecondSmallest();
+ }
+
+ public static void diffLargestAndSmallest() {
+ int[] Array = {12, 34, 56, 69, 2, 78};
+ int diff = 0;
+ int smallest = Array[0];
+ int largest = Array[0];
+ for (int i = 0; i < Array.length; i++) {
+ if (Array.length > 0) {
+ if (smallest > Array[i]) {
+ smallest = Array[i];
+ }
+ if (largest < Array[i]) {
+ largest = Array[i];
+ }
+
+ }
+
+
+ }
+ diff = largest - smallest;
+ System.out.println("The difference between the smallest (" + smallest + ") and largest (" + largest + ") integer of this array is :" + diff);
+ }
+
+ public static void firstAndSecondSmallest() {
+ int[] Array = {12, 34, 56, 69, 2, 78,8};
+ int diff = 0;
+ int firstSmallest = 0;
+ int secondSmallest = 0;
+ if (Array.length > 1) {
+ if (Array[0] > Array[1]) {
+ firstSmallest = Array[0];
+ secondSmallest = Array[1];
+ } else {
+ firstSmallest = Array[1];
+ secondSmallest = Array[0];
+ }
+ for (int i : Array) {
+ if (firstSmallest > i) {
+ secondSmallest = firstSmallest;
+ firstSmallest = i;
+ }
+ if (secondSmallest > i && firstSmallest < i) {
+ secondSmallest = i;
+ }
+
+ }
+ System.out.println("second smallest " + secondSmallest);
+ System.out.println("first smallest " + firstSmallest);
+
+
+ }
+
+ }
+}
diff --git a/src/Company.java b/src/Company.java
new file mode 100644
index 0000000..52985bb
--- /dev/null
+++ b/src/Company.java
@@ -0,0 +1,21 @@
+public class Company {
+ public static void main(String[] args) {
+ Employee[] team = new Employee[10];
+
+ team[0]=new Intern("Salvatore",18,30000);
+ team[1]=new Intern("Céline",22,3400);
+ team[2]=new Intern("Alex",24,4200);
+ team[3]=new Intern("Elodie",19,6500);
+ team[4]=new Intern("Rosca",27,1500);
+ team[5]=new Intern("Ahmad",33,15000);
+ team[6]=new Intern("Cesar",45,16000);
+ team[7]=new Intern("Elise",24,2000);
+ team[8]=new Intern("Tino",50,13000);
+ team[9]=new Intern("Sébastien",26,10000);
+ for(Employee member:team){
+
+ System.out.println(member.toString());;
+ }
+
+ }
+}
diff --git a/src/Employee.java b/src/Employee.java
new file mode 100644
index 0000000..619810e
--- /dev/null
+++ b/src/Employee.java
@@ -0,0 +1,42 @@
+public class Employee {
+ private String name;
+ private int age;
+ private int salary;
+
+ public Employee(String name, int age, int salary) {
+ this.name = name;
+ this.age = age;
+ this.salary = salary;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public int getSalary() {
+ return salary;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public void setSalary(int salary) {
+ this.salary = salary;
+ }
+ public void updateSalary(int newSalary){
+ this.salary = newSalary;
+ }
+ @Override
+ public String toString() {
+ return "Employee Name: " + name +"Age: "+ age + ", Salary: " + salary;
+ }
+}
diff --git a/src/Intern.java b/src/Intern.java
new file mode 100644
index 0000000..da3e7ff
--- /dev/null
+++ b/src/Intern.java
@@ -0,0 +1,22 @@
+public class Intern extends Employee{
+ private static final int maxSalary= 20000;
+ public Intern(String name,int age,int salary){
+ super(name,age,salary);
+ if(salary>maxSalary){
+ throw new IllegalArgumentException("You can not set a salary that exceed "+ maxSalary + " to "+name);
+ }
+
+
+ }
+ @Override
+ public void updateSalary(int newSalary) {
+ if(newSalary<20000){
+ super.updateSalary(newSalary);
+ }
+ else{
+ throw new IllegalArgumentException("You can not set a salary that exceed "+ maxSalary + " to "+super.getName());
+ }
+ }
+
+
+}
From 88a6a2e48e92befb75c15311744d63d08b82505f Mon Sep 17 00:00:00 2001
From: Motodies <39949690+Motodies@users.noreply.github.com>
Date: Sat, 29 Mar 2025 01:32:47 +0100
Subject: [PATCH 03/17] First commit
---
src/Basics.java | 10 +++++-----
src/Company.java | 2 +-
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/Basics.java b/src/Basics.java
index de6fe82..05e6949 100644
--- a/src/Basics.java
+++ b/src/Basics.java
@@ -9,13 +9,13 @@ public static void diffLargestAndSmallest() {
int diff = 0;
int smallest = Array[0];
int largest = Array[0];
- for (int i = 0; i < Array.length; i++) {
+ for (int j : Array) {
if (Array.length > 0) {
- if (smallest > Array[i]) {
- smallest = Array[i];
+ if (smallest > j) {
+ smallest = j;
}
- if (largest < Array[i]) {
- largest = Array[i];
+ if (largest < j) {
+ largest = j;
}
}
diff --git a/src/Company.java b/src/Company.java
index 52985bb..3a6c718 100644
--- a/src/Company.java
+++ b/src/Company.java
@@ -14,7 +14,7 @@ public static void main(String[] args) {
team[9]=new Intern("Sébastien",26,10000);
for(Employee member:team){
- System.out.println(member.toString());;
+ System.out.println(member.toString());
}
}
From 5be3ef8ae1e9cdf309681c0620f2f14b369c4b67 Mon Sep 17 00:00:00 2001
From: Motodies <39949690+Motodies@users.noreply.github.com>
Date: Sat, 29 Mar 2025 01:33:39 +0100
Subject: [PATCH 04/17] First commit
---
src/Employee.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/Employee.java b/src/Employee.java
index 619810e..9b47705 100644
--- a/src/Employee.java
+++ b/src/Employee.java
@@ -35,8 +35,13 @@ public void setSalary(int salary) {
public void updateSalary(int newSalary){
this.salary = newSalary;
}
+
@Override
public String toString() {
- return "Employee Name: " + name +"Age: "+ age + ", Salary: " + salary;
+ return "Employee{" +
+ "name='" + name + '\'' +
+ ", age=" + age +
+ ", salary=" + salary +
+ '}';
}
}
From 0a19761247e130c26f387adcb391aa372c2823ee Mon Sep 17 00:00:00 2001
From: Motodies <39949690+Motodies@users.noreply.github.com>
Date: Sat, 29 Mar 2025 01:37:37 +0100
Subject: [PATCH 05/17] First commit
---
src/Employee.java | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/src/Employee.java b/src/Employee.java
index 9b47705..873e7e4 100644
--- a/src/Employee.java
+++ b/src/Employee.java
@@ -12,26 +12,20 @@ public Employee(String name, int age, int salary) {
public String getName() {
return name;
}
-
- public int getAge() {
- return age;
- }
-
- public int getSalary() {
- return salary;
- }
-
public void setName(String name) {
this.name = name;
}
- public void setAge(int age) {
- this.age = age;
- }
+ public int getAge() {return age;}
+ public void setAge(int age) {this.age = age;}
+ public int getSalary() {
+ return salary;
+ }
public void setSalary(int salary) {
this.salary = salary;
}
+
public void updateSalary(int newSalary){
this.salary = newSalary;
}
From 1c1e1fe42a35bcb8fa9cb6de289eddd878444046 Mon Sep 17 00:00:00 2001
From: Motodies <39949690+Motodies@users.noreply.github.com>
Date: Sat, 29 Mar 2025 01:39:59 +0100
Subject: [PATCH 06/17] First commit
---
.idea/workspace.xml | 79 ++++++++++++++++++++++++++++++++++++++++++---
src/Employee.java | 4 ---
src/Intern.java | 2 +-
3 files changed, 75 insertions(+), 10 deletions(-)
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 56fc85d..c0f60af 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -1,7 +1,7 @@
-
+
@@ -10,10 +10,25 @@
-
+
+
+
+
+ {
+ "customColor": "",
+ "associatedIndex": 0
+}
@@ -22,11 +37,20 @@
+
+
+
+
+
@@ -36,6 +60,51 @@
1743208028728
+
+
+ 1743208213778
+
+
+
+ 1743208213778
+
+
+
+ 1743208291986
+
+
+
+ 1743208291986
+
+
+
+ 1743208367607
+
+
+
+ 1743208367607
+
+
+
+ 1743208420186
+
+
+
+ 1743208420186
+
+
+
+ 1743208658212
+
+
+
+ 1743208658212
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Employee.java b/src/Employee.java
index 873e7e4..626c58f 100644
--- a/src/Employee.java
+++ b/src/Employee.java
@@ -26,10 +26,6 @@ public void setSalary(int salary) {
this.salary = salary;
}
- public void updateSalary(int newSalary){
- this.salary = newSalary;
- }
-
@Override
public String toString() {
return "Employee{" +
diff --git a/src/Intern.java b/src/Intern.java
index da3e7ff..0640700 100644
--- a/src/Intern.java
+++ b/src/Intern.java
@@ -11,7 +11,7 @@ public Intern(String name,int age,int salary){
@Override
public void updateSalary(int newSalary) {
if(newSalary<20000){
- super.updateSalary(newSalary);
+ super.setSalary(newSalary);
}
else{
throw new IllegalArgumentException("You can not set a salary that exceed "+ maxSalary + " to "+super.getName());
From c602e2facf517208abee247c2c597b08359c93a8 Mon Sep 17 00:00:00 2001
From: Motodies <39949690+Motodies@users.noreply.github.com>
Date: Sat, 29 Mar 2025 01:40:29 +0100
Subject: [PATCH 07/17] First commit
---
src/Intern.java | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/Intern.java b/src/Intern.java
index 0640700..9252a25 100644
--- a/src/Intern.java
+++ b/src/Intern.java
@@ -5,10 +5,8 @@ public Intern(String name,int age,int salary){
if(salary>maxSalary){
throw new IllegalArgumentException("You can not set a salary that exceed "+ maxSalary + " to "+name);
}
-
-
}
- @Override
+
public void updateSalary(int newSalary) {
if(newSalary<20000){
super.setSalary(newSalary);
From 0a443b19896bbc36116ca5ee5a17f8226aec2550 Mon Sep 17 00:00:00 2001
From: Motodies <39949690+Motodies@users.noreply.github.com>
Date: Sat, 29 Mar 2025 01:41:49 +0100
Subject: [PATCH 08/17] First commit
---
.idea/workspace.xml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index c0f60af..0ff2e11 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -1,5 +1,8 @@
+
+
+
From 9754b65f9cdb805981013d2369249a9526188052 Mon Sep 17 00:00:00 2001
From: Motodies <39949690+Motodies@users.noreply.github.com>
Date: Sat, 29 Mar 2025 01:42:59 +0100
Subject: [PATCH 09/17] First commit
---
out/production/lab-java-basics/Basics.class | Bin 0 -> 1967 bytes
out/production/lab-java-basics/Company.class | Bin 0 -> 1108 bytes
out/production/lab-java-basics/Employee.class | Bin 0 -> 1534 bytes
out/production/lab-java-basics/Intern.class | Bin 0 -> 1265 bytes
src/Company.java | 2 +-
5 files changed, 1 insertion(+), 1 deletion(-)
create mode 100644 out/production/lab-java-basics/Basics.class
create mode 100644 out/production/lab-java-basics/Company.class
create mode 100644 out/production/lab-java-basics/Employee.class
create mode 100644 out/production/lab-java-basics/Intern.class
diff --git a/out/production/lab-java-basics/Basics.class b/out/production/lab-java-basics/Basics.class
new file mode 100644
index 0000000000000000000000000000000000000000..f8d4611a9c9593c180aa8046ced6d410723781f3
GIT binary patch
literal 1967
zcmah~T~8xb7=8|&c1kHw3I&mmEiCJnime|kyYf*51i>v^v;@O?`
zv>~8Ei6V%QKeUkljFPeSLk>
z58&lSZ{66Ni{MoZsThu81fv4IElv+X3~gA`IXLriYRA&_(_jJb$b$Hb{|Qb1WY
zD^j34uN(5wQEf+BTiQ;QmU!MQYt?Pd(%p5#s5tvNsfY8v#B=noX*yZ-ryjSW!F|e4
zkKPvB0^)$rx95o5Rq;iA
z1-k5O)f9*n%_FNUS9LeD4xfC+6_&MKGEK*JEUmsFoqe-nhcPcu+}f8(mx#2aQI^Ra
z>3kujk#uN&K`faPlS$2}BpdX+HLD``q?I&xiPi0-=4O`UWLAX1e(mw8T?L`}eX{T}
zXtH*PuoU54_&~*qTgO#_iK}a%8^`9M%=#VUch{;`c1(*R{?ObI4WOUe8p-kkOyo`T
z@Tfj_vtUh@YmQqdb=d;mTvPvI&NcUQBg8UqT~T)=n`~!iU_KqlEbz&tXO%(aVkQ`v2_-^_;3@77Dv3~L
zMonM*h{SM0Jwqs=E{r79Q+Ja4HYA>0{yj2Wng0dd!y`lINC3ZL&?O!4a-QYa4&?tYgWV(AUBPGjo-
zh*gS(VqsUZz(OFGzEI9kr*LT{bA~QYMJ1Daf({y53z}{S>S-As&iQJdAxcA&rhie-
zk#pSg)O58yXYSXP{RDkpmMNmrNHY5|YBP>$cF_X$S)_hz?5;c&+9X0}i#`o|ccOtZ|u|@J2{1@qKr{(|v
literal 0
HcmV?d00001
diff --git a/out/production/lab-java-basics/Company.class b/out/production/lab-java-basics/Company.class
new file mode 100644
index 0000000000000000000000000000000000000000..644f7a52bf4108bf4d13575b0d4ec015f3319fa2
GIT binary patch
literal 1108
zcmZuvOHUI~7(KV0cBVstnU?oM!51yBDk{pu3f2-a1&t*nhSjA^U~nE}IuO|y7yba3
zuGtut8Uu+BHg1S36WwTB`x{(|-`v3{fyvB$obP_;e&>Ai>G#_`00m5`h#)FMN+O0h
zgSN^yc+TR^a_-*Zs!{P7;^U@c`gw+ECOa=fVNiC9-E%d&MVLvFp4`Q!E?ullCpBybkz
zWSmdp0(y>!EN@nQ!zOL+I!SE|>oncmeJawYQVnj8sgRLPq8EK6-FHI)3=Ns=aak$`
zFeoFJ#6?_UNDJLZ`AG6wz-~Eo;R((JCSMMGaqTtkY?7pcyJRrbm&m2rb$ik9=J=vT
zNUG#kxHZo`GuR)3lD}eBsS~Bc{4pZ1xk;BbWfqPXoSi4HZ6jbM%SwMc8)R{BnTXOS
zBvH^OXBcW0{?Di_`@HgKhOdcIWaMQ`1buMVy^1kq1|=sCs~QZ9K{tlz_Y0l~sEdfx
zc!hR3ni|vkV}2hcSt-;
z)o3Ywwrdx)eUOqZ3HAhOln??cBIn!lkzIN3#9`*dy$0Phi#aZ5&lUPit6
Mg$@eerf>wsKiJ6XH~;_u
literal 0
HcmV?d00001
diff --git a/out/production/lab-java-basics/Employee.class b/out/production/lab-java-basics/Employee.class
new file mode 100644
index 0000000000000000000000000000000000000000..117d8acec3ee8dea0cdaaa49c77cd1e89f5abb2a
GIT binary patch
literal 1534
zcmaKsTTc@~6vzKV%WkP#p{0P_1O=omNWEVukZ2>ZNyUc}eDG-~ld`bgZFUEe#`rz_
z5I$%kG2y`v;D<7v+1*~Giw`^3Gw1xy`Ooa{KbOA%l(Ct_5Mnyw28N+AjGgdvUbMK~
zD84^D5p~I+ZJD+ycNk*1{J{tk7}1e5a03QI;!U$rx;9dOrF^KdaPk4=i4tag$uG3X5;
z_xyyjxyazU*D;ugz{nGXMlN2dYEWG(stVyWo~x+s5!$Z#g`qL+b;b$l1a&2%nsesX
z#jdH)QysbuB>*Y;+Hs^OUEX>pFbG{UEK+&__6}Jq$C{7a164m0P^e*~eGij?RToYR;TY~>
zDfHD3lKOfDWIPgN87tx8%`V6+m8}O7q>;S_Le)iOe=iaueHCIV5@NLr(W?eQ^vM=f
zV}`0Rdku(^MS0U0F=eJT3Vm!u%BYP8Ttl?f{xL*6f70c+H&tF}SkI-bxh
MNu#HDj+dDJ3q4sK7XSbN
literal 0
HcmV?d00001
diff --git a/out/production/lab-java-basics/Intern.class b/out/production/lab-java-basics/Intern.class
new file mode 100644
index 0000000000000000000000000000000000000000..0552cec49e9444dd4574515f325e208d3473cd62
GIT binary patch
literal 1265
zcmaKrT~8B16o%hv3)?R!t$c`3T@bJorHJ2xCfY!3QtCxX4e@H&PTHm0*=Bc&@DKb6
zUKM#n
zrjTmy%n&VQ+A>91<8e%2l60HAA@a5~xO!u%I$5sbQn?IkBQmZJLqrk5ln0(CsP
z@v6HL$24XbBCb$nZgJ)O({z4=CN=N`LRVSsiJLgtHK@AoA(w&s%}!T;iA8VI}|Uw2&v&x
z8G^j#HO1{!Fi}?AXdLiXS4_h?!_?*W`(0v)w_8=NL?1jN#k;;8E!%C!5c{Ub7xNJ|
zJp~eaY1_(G4sRU@Rky2d7+VavBfG5|T^m_xUb=X*YSr8E0=_(JhdC5cbxn~u+I%;d)@gk*vp=yPx6Y(swLc&qHQX5NoV&+D}E9w8b)I=iu$?trC}CH)hUUlBRl
zxIhf(Ao2YRIRtToo~f>Lh{VS*Ng|5~L#OquFG6XTX-0Cmi4{uWS*w)ZLrG(etRQZY
zodo+u!66Nrh79u@8HvpFs2b$vg)A))&PT+u3mv3BW7@;Yb};)-vKW!Yk)WYd4xJ=s
seW5>OOW5dcher`YATdR$Zj&9r9c
Date: Sat, 29 Mar 2025 01:42:59 +0100
Subject: [PATCH 10/17] First commit
---
out/production/lab-java-basics/Basics.class | Bin 0 -> 1967 bytes
out/production/lab-java-basics/Company.class | Bin 0 -> 1108 bytes
out/production/lab-java-basics/Employee.class | Bin 0 -> 1534 bytes
out/production/lab-java-basics/Intern.class | Bin 0 -> 1265 bytes
src/Company.java | 2 +-
5 files changed, 1 insertion(+), 1 deletion(-)
create mode 100644 out/production/lab-java-basics/Basics.class
create mode 100644 out/production/lab-java-basics/Company.class
create mode 100644 out/production/lab-java-basics/Employee.class
create mode 100644 out/production/lab-java-basics/Intern.class
diff --git a/out/production/lab-java-basics/Basics.class b/out/production/lab-java-basics/Basics.class
new file mode 100644
index 0000000000000000000000000000000000000000..f8d4611a9c9593c180aa8046ced6d410723781f3
GIT binary patch
literal 1967
zcmah~T~8xb7=8|&c1kHw3I&mmEiCJnime|kyYf*51i>v^v;@O?`
zv>~8Ei6V%QKeUkljFPeSLk>
z58&lSZ{66Ni{MoZsThu81fv4IElv+X3~gA`IXLriYRA&_(_jJb$b$Hb{|Qb1WY
zD^j34uN(5wQEf+BTiQ;QmU!MQYt?Pd(%p5#s5tvNsfY8v#B=noX*yZ-ryjSW!F|e4
zkKPvB0^)$rx95o5Rq;iA
z1-k5O)f9*n%_FNUS9LeD4xfC+6_&MKGEK*JEUmsFoqe-nhcPcu+}f8(mx#2aQI^Ra
z>3kujk#uN&K`faPlS$2}BpdX+HLD``q?I&xiPi0-=4O`UWLAX1e(mw8T?L`}eX{T}
zXtH*PuoU54_&~*qTgO#_iK}a%8^`9M%=#VUch{;`c1(*R{?ObI4WOUe8p-kkOyo`T
z@Tfj_vtUh@YmQqdb=d;mTvPvI&NcUQBg8UqT~T)=n`~!iU_KqlEbz&tXO%(aVkQ`v2_-^_;3@77Dv3~L
zMonM*h{SM0Jwqs=E{r79Q+Ja4HYA>0{yj2Wng0dd!y`lINC3ZL&?O!4a-QYa4&?tYgWV(AUBPGjo-
zh*gS(VqsUZz(OFGzEI9kr*LT{bA~QYMJ1Daf({y53z}{S>S-As&iQJdAxcA&rhie-
zk#pSg)O58yXYSXP{RDkpmMNmrNHY5|YBP>$cF_X$S)_hz?5;c&+9X0}i#`o|ccOtZ|u|@J2{1@qKr{(|v
literal 0
HcmV?d00001
diff --git a/out/production/lab-java-basics/Company.class b/out/production/lab-java-basics/Company.class
new file mode 100644
index 0000000000000000000000000000000000000000..644f7a52bf4108bf4d13575b0d4ec015f3319fa2
GIT binary patch
literal 1108
zcmZuvOHUI~7(KV0cBVstnU?oM!51yBDk{pu3f2-a1&t*nhSjA^U~nE}IuO|y7yba3
zuGtut8Uu+BHg1S36WwTB`x{(|-`v3{fyvB$obP_;e&>Ai>G#_`00m5`h#)FMN+O0h
zgSN^yc+TR^a_-*Zs!{P7;^U@c`gw+ECOa=fVNiC9-E%d&MVLvFp4`Q!E?ullCpBybkz
zWSmdp0(y>!EN@nQ!zOL+I!SE|>oncmeJawYQVnj8sgRLPq8EK6-FHI)3=Ns=aak$`
zFeoFJ#6?_UNDJLZ`AG6wz-~Eo;R((JCSMMGaqTtkY?7pcyJRrbm&m2rb$ik9=J=vT
zNUG#kxHZo`GuR)3lD}eBsS~Bc{4pZ1xk;BbWfqPXoSi4HZ6jbM%SwMc8)R{BnTXOS
zBvH^OXBcW0{?Di_`@HgKhOdcIWaMQ`1buMVy^1kq1|=sCs~QZ9K{tlz_Y0l~sEdfx
zc!hR3ni|vkV}2hcSt-;
z)o3Ywwrdx)eUOqZ3HAhOln??cBIn!lkzIN3#9`*dy$0Phi#aZ5&lUPit6
Mg$@eerf>wsKiJ6XH~;_u
literal 0
HcmV?d00001
diff --git a/out/production/lab-java-basics/Employee.class b/out/production/lab-java-basics/Employee.class
new file mode 100644
index 0000000000000000000000000000000000000000..117d8acec3ee8dea0cdaaa49c77cd1e89f5abb2a
GIT binary patch
literal 1534
zcmaKsTTc@~6vzKV%WkP#p{0P_1O=omNWEVukZ2>ZNyUc}eDG-~ld`bgZFUEe#`rz_
z5I$%kG2y`v;D<7v+1*~Giw`^3Gw1xy`Ooa{KbOA%l(Ct_5Mnyw28N+AjGgdvUbMK~
zD84^D5p~I+ZJD+ycNk*1{J{tk7}1e5a03QI;!U$rx;9dOrF^KdaPk4=i4tag$uG3X5;
z_xyyjxyazU*D;ugz{nGXMlN2dYEWG(stVyWo~x+s5!$Z#g`qL+b;b$l1a&2%nsesX
z#jdH)QysbuB>*Y;+Hs^OUEX>pFbG{UEK+&__6}Jq$C{7a164m0P^e*~eGij?RToYR;TY~>
zDfHD3lKOfDWIPgN87tx8%`V6+m8}O7q>;S_Le)iOe=iaueHCIV5@NLr(W?eQ^vM=f
zV}`0Rdku(^MS0U0F=eJT3Vm!u%BYP8Ttl?f{xL*6f70c+H&tF}SkI-bxh
MNu#HDj+dDJ3q4sK7XSbN
literal 0
HcmV?d00001
diff --git a/out/production/lab-java-basics/Intern.class b/out/production/lab-java-basics/Intern.class
new file mode 100644
index 0000000000000000000000000000000000000000..0552cec49e9444dd4574515f325e208d3473cd62
GIT binary patch
literal 1265
zcmaKrT~8B16o%hv3)?R!t$c`3T@bJorHJ2xCfY!3QtCxX4e@H&PTHm0*=Bc&@DKb6
zUKM#n
zrjTmy%n&VQ+A>91<8e%2l60HAA@a5~xO!u%I$5sbQn?IkBQmZJLqrk5ln0(CsP
z@v6HL$24XbBCb$nZgJ)O({z4=CN=N`LRVSsiJLgtHK@AoA(w&s%}!T;iA8VI}|Uw2&v&x
z8G^j#HO1{!Fi}?AXdLiXS4_h?!_?*W`(0v)w_8=NL?1jN#k;;8E!%C!5c{Ub7xNJ|
zJp~eaY1_(G4sRU@Rky2d7+VavBfG5|T^m_xUb=X*YSr8E0=_(JhdC5cbxn~u+I%;d)@gk*vp=yPx6Y(swLc&qHQX5NoV&+D}E9w8b)I=iu$?trC}CH)hUUlBRl
zxIhf(Ao2YRIRtToo~f>Lh{VS*Ng|5~L#OquFG6XTX-0Cmi4{uWS*w)ZLrG(etRQZY
zodo+u!66Nrh79u@8HvpFs2b$vg)A))&PT+u3mv3BW7@;Yb};)-vKW!Yk)WYd4xJ=s
seW5>OOW5dcher`YATdR$Zj&9r9c
Date: Sat, 29 Mar 2025 01:45:11 +0100
Subject: [PATCH 11/17] First commit
---
.idea/workspace.xml | 35 +++++++++++++++++-
out/production/lab-java-basics/Basics.class | Bin 1967 -> 0 bytes
out/production/lab-java-basics/Company.class | Bin 1108 -> 0 bytes
out/production/lab-java-basics/Employee.class | Bin 1534 -> 0 bytes
out/production/lab-java-basics/Intern.class | Bin 1265 -> 0 bytes
5 files changed, 34 insertions(+), 1 deletion(-)
delete mode 100644 out/production/lab-java-basics/Basics.class
delete mode 100644 out/production/lab-java-basics/Company.class
delete mode 100644 out/production/lab-java-basics/Employee.class
delete mode 100644 out/production/lab-java-basics/Intern.class
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 0ff2e11..2bdebfc 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -39,6 +39,7 @@
1743208658212
-
+
+
+ 1743208799963
+
+
+
+ 1743208799963
+
+
+
+ 1743208830221
+
+
+
+ 1743208830221
+
+
+
+ 1743208910416
+
+
+
+ 1743208910416
+
+
+
+ 1743208991981
+
+
+
+ 1743208991981
+
+
diff --git a/out/production/lab-java-basics/Basics.class b/out/production/lab-java-basics/Basics.class
deleted file mode 100644
index f8d4611a9c9593c180aa8046ced6d410723781f3..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 1967
zcmah~T~8xb7=8|&c1kHw3I&mmEiCJnime|kyYf*51i>v^v;@O?`
zv>~8Ei6V%QKeUkljFPeSLk>
z58&lSZ{66Ni{MoZsThu81fv4IElv+X3~gA`IXLriYRA&_(_jJb$b$Hb{|Qb1WY
zD^j34uN(5wQEf+BTiQ;QmU!MQYt?Pd(%p5#s5tvNsfY8v#B=noX*yZ-ryjSW!F|e4
zkKPvB0^)$rx95o5Rq;iA
z1-k5O)f9*n%_FNUS9LeD4xfC+6_&MKGEK*JEUmsFoqe-nhcPcu+}f8(mx#2aQI^Ra
z>3kujk#uN&K`faPlS$2}BpdX+HLD``q?I&xiPi0-=4O`UWLAX1e(mw8T?L`}eX{T}
zXtH*PuoU54_&~*qTgO#_iK}a%8^`9M%=#VUch{;`c1(*R{?ObI4WOUe8p-kkOyo`T
z@Tfj_vtUh@YmQqdb=d;mTvPvI&NcUQBg8UqT~T)=n`~!iU_KqlEbz&tXO%(aVkQ`v2_-^_;3@77Dv3~L
zMonM*h{SM0Jwqs=E{r79Q+Ja4HYA>0{yj2Wng0dd!y`lINC3ZL&?O!4a-QYa4&?tYgWV(AUBPGjo-
zh*gS(VqsUZz(OFGzEI9kr*LT{bA~QYMJ1Daf({y53z}{S>S-As&iQJdAxcA&rhie-
zk#pSg)O58yXYSXP{RDkpmMNmrNHY5|YBP>$cF_X$S)_hz?5;c&+9X0}i#`o|ccOtZ|u|@J2{1@qKr{(|v
diff --git a/out/production/lab-java-basics/Company.class b/out/production/lab-java-basics/Company.class
deleted file mode 100644
index 644f7a52bf4108bf4d13575b0d4ec015f3319fa2..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 1108
zcmZuvOHUI~7(KV0cBVstnU?oM!51yBDk{pu3f2-a1&t*nhSjA^U~nE}IuO|y7yba3
zuGtut8Uu+BHg1S36WwTB`x{(|-`v3{fyvB$obP_;e&>Ai>G#_`00m5`h#)FMN+O0h
zgSN^yc+TR^a_-*Zs!{P7;^U@c`gw+ECOa=fVNiC9-E%d&MVLvFp4`Q!E?ullCpBybkz
zWSmdp0(y>!EN@nQ!zOL+I!SE|>oncmeJawYQVnj8sgRLPq8EK6-FHI)3=Ns=aak$`
zFeoFJ#6?_UNDJLZ`AG6wz-~Eo;R((JCSMMGaqTtkY?7pcyJRrbm&m2rb$ik9=J=vT
zNUG#kxHZo`GuR)3lD}eBsS~Bc{4pZ1xk;BbWfqPXoSi4HZ6jbM%SwMc8)R{BnTXOS
zBvH^OXBcW0{?Di_`@HgKhOdcIWaMQ`1buMVy^1kq1|=sCs~QZ9K{tlz_Y0l~sEdfx
zc!hR3ni|vkV}2hcSt-;
z)o3Ywwrdx)eUOqZ3HAhOln??cBIn!lkzIN3#9`*dy$0Phi#aZ5&lUPit6
Mg$@eerf>wsKiJ6XH~;_u
diff --git a/out/production/lab-java-basics/Employee.class b/out/production/lab-java-basics/Employee.class
deleted file mode 100644
index 117d8acec3ee8dea0cdaaa49c77cd1e89f5abb2a..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 1534
zcmaKsTTc@~6vzKV%WkP#p{0P_1O=omNWEVukZ2>ZNyUc}eDG-~ld`bgZFUEe#`rz_
z5I$%kG2y`v;D<7v+1*~Giw`^3Gw1xy`Ooa{KbOA%l(Ct_5Mnyw28N+AjGgdvUbMK~
zD84^D5p~I+ZJD+ycNk*1{J{tk7}1e5a03QI;!U$rx;9dOrF^KdaPk4=i4tag$uG3X5;
z_xyyjxyazU*D;ugz{nGXMlN2dYEWG(stVyWo~x+s5!$Z#g`qL+b;b$l1a&2%nsesX
z#jdH)QysbuB>*Y;+Hs^OUEX>pFbG{UEK+&__6}Jq$C{7a164m0P^e*~eGij?RToYR;TY~>
zDfHD3lKOfDWIPgN87tx8%`V6+m8}O7q>;S_Le)iOe=iaueHCIV5@NLr(W?eQ^vM=f
zV}`0Rdku(^MS0U0F=eJT3Vm!u%BYP8Ttl?f{xL*6f70c+H&tF}SkI-bxh
MNu#HDj+dDJ3q4sK7XSbN
diff --git a/out/production/lab-java-basics/Intern.class b/out/production/lab-java-basics/Intern.class
deleted file mode 100644
index 0552cec49e9444dd4574515f325e208d3473cd62..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 1265
zcmaKrT~8B16o%hv3)?R!t$c`3T@bJorHJ2xCfY!3QtCxX4e@H&PTHm0*=Bc&@DKb6
zUKM#n
zrjTmy%n&VQ+A>91<8e%2l60HAA@a5~xO!u%I$5sbQn?IkBQmZJLqrk5ln0(CsP
z@v6HL$24XbBCb$nZgJ)O({z4=CN=N`LRVSsiJLgtHK@AoA(w&s%}!T;iA8VI}|Uw2&v&x
z8G^j#HO1{!Fi}?AXdLiXS4_h?!_?*W`(0v)w_8=NL?1jN#k;;8E!%C!5c{Ub7xNJ|
zJp~eaY1_(G4sRU@Rky2d7+VavBfG5|T^m_xUb=X*YSr8E0=_(JhdC5cbxn~u+I%;d)@gk*vp=yPx6Y(swLc&qHQX5NoV&+D}E9w8b)I=iu$?trC}CH)hUUlBRl
zxIhf(Ao2YRIRtToo~f>Lh{VS*Ng|5~L#OquFG6XTX-0Cmi4{uWS*w)ZLrG(etRQZY
zodo+u!66Nrh79u@8HvpFs2b$vg)A))&PT+u3mv3BW7@;Yb};)-vKW!Yk)WYd4xJ=s
seW5>OOW5dcher`YATdR$Zj&9r9c
Date: Sat, 29 Mar 2025 01:46:41 +0100
Subject: [PATCH 12/17] First commit
---
out/production/lab-java-basics/Basics.class | Bin 1967 -> 0 bytes
out/production/lab-java-basics/Company.class | Bin 1108 -> 0 bytes
out/production/lab-java-basics/Employee.class | Bin 1534 -> 0 bytes
out/production/lab-java-basics/Intern.class | Bin 1265 -> 0 bytes
4 files changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 out/production/lab-java-basics/Basics.class
delete mode 100644 out/production/lab-java-basics/Company.class
delete mode 100644 out/production/lab-java-basics/Employee.class
delete mode 100644 out/production/lab-java-basics/Intern.class
diff --git a/out/production/lab-java-basics/Basics.class b/out/production/lab-java-basics/Basics.class
deleted file mode 100644
index f8d4611a9c9593c180aa8046ced6d410723781f3..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 1967
zcmah~T~8xb7=8|&c1kHw3I&mmEiCJnime|kyYf*51i>v^v;@O?`
zv>~8Ei6V%QKeUkljFPeSLk>
z58&lSZ{66Ni{MoZsThu81fv4IElv+X3~gA`IXLriYRA&_(_jJb$b$Hb{|Qb1WY
zD^j34uN(5wQEf+BTiQ;QmU!MQYt?Pd(%p5#s5tvNsfY8v#B=noX*yZ-ryjSW!F|e4
zkKPvB0^)$rx95o5Rq;iA
z1-k5O)f9*n%_FNUS9LeD4xfC+6_&MKGEK*JEUmsFoqe-nhcPcu+}f8(mx#2aQI^Ra
z>3kujk#uN&K`faPlS$2}BpdX+HLD``q?I&xiPi0-=4O`UWLAX1e(mw8T?L`}eX{T}
zXtH*PuoU54_&~*qTgO#_iK}a%8^`9M%=#VUch{;`c1(*R{?ObI4WOUe8p-kkOyo`T
z@Tfj_vtUh@YmQqdb=d;mTvPvI&NcUQBg8UqT~T)=n`~!iU_KqlEbz&tXO%(aVkQ`v2_-^_;3@77Dv3~L
zMonM*h{SM0Jwqs=E{r79Q+Ja4HYA>0{yj2Wng0dd!y`lINC3ZL&?O!4a-QYa4&?tYgWV(AUBPGjo-
zh*gS(VqsUZz(OFGzEI9kr*LT{bA~QYMJ1Daf({y53z}{S>S-As&iQJdAxcA&rhie-
zk#pSg)O58yXYSXP{RDkpmMNmrNHY5|YBP>$cF_X$S)_hz?5;c&+9X0}i#`o|ccOtZ|u|@J2{1@qKr{(|v
diff --git a/out/production/lab-java-basics/Company.class b/out/production/lab-java-basics/Company.class
deleted file mode 100644
index 644f7a52bf4108bf4d13575b0d4ec015f3319fa2..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 1108
zcmZuvOHUI~7(KV0cBVstnU?oM!51yBDk{pu3f2-a1&t*nhSjA^U~nE}IuO|y7yba3
zuGtut8Uu+BHg1S36WwTB`x{(|-`v3{fyvB$obP_;e&>Ai>G#_`00m5`h#)FMN+O0h
zgSN^yc+TR^a_-*Zs!{P7;^U@c`gw+ECOa=fVNiC9-E%d&MVLvFp4`Q!E?ullCpBybkz
zWSmdp0(y>!EN@nQ!zOL+I!SE|>oncmeJawYQVnj8sgRLPq8EK6-FHI)3=Ns=aak$`
zFeoFJ#6?_UNDJLZ`AG6wz-~Eo;R((JCSMMGaqTtkY?7pcyJRrbm&m2rb$ik9=J=vT
zNUG#kxHZo`GuR)3lD}eBsS~Bc{4pZ1xk;BbWfqPXoSi4HZ6jbM%SwMc8)R{BnTXOS
zBvH^OXBcW0{?Di_`@HgKhOdcIWaMQ`1buMVy^1kq1|=sCs~QZ9K{tlz_Y0l~sEdfx
zc!hR3ni|vkV}2hcSt-;
z)o3Ywwrdx)eUOqZ3HAhOln??cBIn!lkzIN3#9`*dy$0Phi#aZ5&lUPit6
Mg$@eerf>wsKiJ6XH~;_u
diff --git a/out/production/lab-java-basics/Employee.class b/out/production/lab-java-basics/Employee.class
deleted file mode 100644
index 117d8acec3ee8dea0cdaaa49c77cd1e89f5abb2a..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 1534
zcmaKsTTc@~6vzKV%WkP#p{0P_1O=omNWEVukZ2>ZNyUc}eDG-~ld`bgZFUEe#`rz_
z5I$%kG2y`v;D<7v+1*~Giw`^3Gw1xy`Ooa{KbOA%l(Ct_5Mnyw28N+AjGgdvUbMK~
zD84^D5p~I+ZJD+ycNk*1{J{tk7}1e5a03QI;!U$rx;9dOrF^KdaPk4=i4tag$uG3X5;
z_xyyjxyazU*D;ugz{nGXMlN2dYEWG(stVyWo~x+s5!$Z#g`qL+b;b$l1a&2%nsesX
z#jdH)QysbuB>*Y;+Hs^OUEX>pFbG{UEK+&__6}Jq$C{7a164m0P^e*~eGij?RToYR;TY~>
zDfHD3lKOfDWIPgN87tx8%`V6+m8}O7q>;S_Le)iOe=iaueHCIV5@NLr(W?eQ^vM=f
zV}`0Rdku(^MS0U0F=eJT3Vm!u%BYP8Ttl?f{xL*6f70c+H&tF}SkI-bxh
MNu#HDj+dDJ3q4sK7XSbN
diff --git a/out/production/lab-java-basics/Intern.class b/out/production/lab-java-basics/Intern.class
deleted file mode 100644
index 0552cec49e9444dd4574515f325e208d3473cd62..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 1265
zcmaKrT~8B16o%hv3)?R!t$c`3T@bJorHJ2xCfY!3QtCxX4e@H&PTHm0*=Bc&@DKb6
zUKM#n
zrjTmy%n&VQ+A>91<8e%2l60HAA@a5~xO!u%I$5sbQn?IkBQmZJLqrk5ln0(CsP
z@v6HL$24XbBCb$nZgJ)O({z4=CN=N`LRVSsiJLgtHK@AoA(w&s%}!T;iA8VI}|Uw2&v&x
z8G^j#HO1{!Fi}?AXdLiXS4_h?!_?*W`(0v)w_8=NL?1jN#k;;8E!%C!5c{Ub7xNJ|
zJp~eaY1_(G4sRU@Rky2d7+VavBfG5|T^m_xUb=X*YSr8E0=_(JhdC5cbxn~u+I%;d)@gk*vp=yPx6Y(swLc&qHQX5NoV&+D}E9w8b)I=iu$?trC}CH)hUUlBRl
zxIhf(Ao2YRIRtToo~f>Lh{VS*Ng|5~L#OquFG6XTX-0Cmi4{uWS*w)ZLrG(etRQZY
zodo+u!66Nrh79u@8HvpFs2b$vg)A))&PT+u3mv3BW7@;Yb};)-vKW!Yk)WYd4xJ=s
seW5>OOW5dcher`YATdR$Zj&9r9c
Date: Sat, 29 Mar 2025 09:15:59 +0100
Subject: [PATCH 13/17] Some optimisation and commenting
---
.idea/workspace.xml | 37 ++++++++++++++++++--
src/Basics.java | 84 +++++++++++++++++++++++++++------------------
src/Company.java | 27 ++++++++-------
src/Employee.java | 20 +++++++++--
src/Intern.java | 32 ++++++++++-------
5 files changed, 138 insertions(+), 62 deletions(-)
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 2bdebfc..dde1643 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,7 +4,13 @@
-
+
+
+
+
+
+
+
@@ -136,11 +142,36 @@
1743208991981
-
+
+
+ 1743209079368
+
+
+
+ 1743209079368
+
+
+
+ 1743209117232
+
+
+
+ 1743209117232
+
+
+
+ 1743209203969
+
+
+
+ 1743209203969
+
+
-
+
+
\ No newline at end of file
diff --git a/src/Basics.java b/src/Basics.java
index 05e6949..792d569 100644
--- a/src/Basics.java
+++ b/src/Basics.java
@@ -1,59 +1,77 @@
public class Basics {
public static void main(String[] args) {
+ // Call methods to calculate the difference between the largest and smallest element,
+ // and to find the two smallest elements in the array.
diffLargestAndSmallest();
firstAndSecondSmallest();
}
+ /**
+ * Method to calculate the difference between the largest and smallest element in an array.
+ */
public static void diffLargestAndSmallest() {
- int[] Array = {12, 34, 56, 69, 2, 78};
- int diff = 0;
- int smallest = Array[0];
- int largest = Array[0];
- for (int j : Array) {
- if (Array.length > 0) {
+ // Initialize the array with values.
+ int[] array = {12, 34, 56, 69, 2, 78};
+
+ // Initialize variables to store the smallest and largest elements.
+ int smallest = array[0];
+ int largest = array[0];
+
+ // Iterate through each element in the array.
+ if(array.length>0){
+ for (int j : array) {
+ // Update the smallest element if the current element is smaller.
if (smallest > j) {
smallest = j;
}
+ // Update the largest element if the current element is larger.
if (largest < j) {
largest = j;
}
-
}
-
}
- diff = largest - smallest;
- System.out.println("The difference between the smallest (" + smallest + ") and largest (" + largest + ") integer of this array is :" + diff);
+
+
+ // Calculate the difference between the largest and smallest elements.
+ int diff = largest - smallest;
+
+ // Print the result.
+ System.out.println("The difference between the smallest (" + smallest + ") and largest (" + largest + ") integer of this array is: " + diff);
}
+ /**
+ * Method to find the two smallest elements in an array.
+ */
public static void firstAndSecondSmallest() {
- int[] Array = {12, 34, 56, 69, 2, 78,8};
- int diff = 0;
- int firstSmallest = 0;
- int secondSmallest = 0;
- if (Array.length > 1) {
- if (Array[0] > Array[1]) {
- firstSmallest = Array[0];
- secondSmallest = Array[1];
- } else {
- firstSmallest = Array[1];
- secondSmallest = Array[0];
- }
- for (int i : Array) {
- if (firstSmallest > i) {
- secondSmallest = firstSmallest;
- firstSmallest = i;
- }
- if (secondSmallest > i && firstSmallest < i) {
- secondSmallest = i;
- }
+ // Initialize the array with values.
+ int[] array = {12, 34, 56, 69, 2, 78, 8};
- }
- System.out.println("second smallest " + secondSmallest);
- System.out.println("first smallest " + firstSmallest);
+ // Check that the array contains at least two elements.
+ if (array.length < 2) {
+ System.out.println("Array must have at least two elements.");
+ return;
+ }
+ // Initialize variables to store the two smallest elements.
+ int firstSmallest = Integer.MAX_VALUE;
+ int secondSmallest = Integer.MAX_VALUE;
+ // Iterate through each element in the array.
+ for (int i : array) {
+ // Update the first smallest element if the current element is smaller.
+ if (firstSmallest > i) {
+ secondSmallest = firstSmallest;
+ firstSmallest = i;
+ }
+ // Update the second smallest element if the current element is smaller than the second smallest but larger than the first smallest.
+ else if (secondSmallest > i) {
+ secondSmallest = i;
+ }
}
+ // Print the two smallest elements.
+ System.out.println("First smallest: " + firstSmallest);
+ System.out.println("Second smallest: " + secondSmallest);
}
}
diff --git a/src/Company.java b/src/Company.java
index 3b49656..20c1823 100644
--- a/src/Company.java
+++ b/src/Company.java
@@ -1,21 +1,24 @@
public class Company {
public static void main(String[] args) {
+ // Create an array to hold 10 Employee objects.
Employee[] team = new Employee[10];
- team[0]=new Intern("Salvatore",18,20000);
- team[1]=new Intern("Céline",22,3400);
- team[2]=new Intern("Alex",24,4200);
- team[3]=new Intern("Elodie",19,6500);
- team[4]=new Intern("Rosca",27,1500);
- team[5]=new Intern("Ahmad",33,15000);
- team[6]=new Intern("Cesar",45,16000);
- team[7]=new Intern("Elise",24,2000);
- team[8]=new Intern("Tino",50,13000);
- team[9]=new Intern("Sébastien",26,10000);
- for(Employee member:team){
+ // Initialize each element of the array with an Intern object.
+ team[0] = new Intern("Salvatore", 18, 20000);
+ team[1] = new Intern("Céline", 22, 3400);
+ team[2] = new Intern("Alex", 24, 4200);
+ team[3] = new Intern("Elodie", 19, 6500);
+ team[4] = new Intern("Rosca", 27, 1500);
+ team[5] = new Intern("Ahmad", 33, 15000);
+ team[6] = new Intern("Cesar", 45, 16000);
+ team[7] = new Intern("Elise", 24, 2000);
+ team[8] = new Intern("Tino", 50, 13000);
+ team[9] = new Intern("Sébastien", 26, 10000);
+ // Iterate through each Employee in the team array.
+ for (Employee member : team) {
+ // Print the string representation of each Employee.
System.out.println(member.toString());
}
-
}
}
diff --git a/src/Employee.java b/src/Employee.java
index 626c58f..74eba49 100644
--- a/src/Employee.java
+++ b/src/Employee.java
@@ -1,31 +1,47 @@
public class Employee {
+ // Private fields to store the employee's name, age, and salary.
private String name;
private int age;
private int salary;
+ // Constructor to initialize the Employee object with name, age, and salary.
public Employee(String name, int age, int salary) {
this.name = name;
this.age = age;
this.salary = salary;
}
+ // Getter method for the name field.
public String getName() {
return name;
}
+
+ // Setter method for the name field.
public void setName(String name) {
this.name = name;
}
- public int getAge() {return age;}
- public void setAge(int age) {this.age = age;}
+ // Getter method for the age field.
+ public int getAge() {
+ return age;
+ }
+
+ // Setter method for the age field.
+ public void setAge(int age) {
+ this.age = age;
+ }
+ // Getter method for the salary field.
public int getSalary() {
return salary;
}
+
+ // Setter method for the salary field.
public void setSalary(int salary) {
this.salary = salary;
}
+ // Override the toString method to provide a string representation of the Employee object.
@Override
public String toString() {
return "Employee{" +
diff --git a/src/Intern.java b/src/Intern.java
index 9252a25..eadd3d2 100644
--- a/src/Intern.java
+++ b/src/Intern.java
@@ -1,20 +1,28 @@
-public class Intern extends Employee{
- private static final int maxSalary= 20000;
- public Intern(String name,int age,int salary){
- super(name,age,salary);
- if(salary>maxSalary){
- throw new IllegalArgumentException("You can not set a salary that exceed "+ maxSalary + " to "+name);
+public class Intern extends Employee {
+ // Define a constant for the maximum salary an intern can have.
+ private static final int maxSalary = 20000;
+
+ // Constructor for the Intern class.
+ public Intern(String name, int age, int salary) {
+ // Call the constructor of the superclass (Employee) with the provided name, age, and salary.
+ super(name, age, salary);
+
+ // Check if the provided salary exceeds the maximum allowed salary.
+ if (salary > maxSalary) {
+ // Throw an IllegalArgumentException if the salary is too high.
+ throw new IllegalArgumentException("You cannot set a salary that exceeds " + maxSalary + " for " + name);
}
}
+ // Method to update the salary of the intern.
public void updateSalary(int newSalary) {
- if(newSalary<20000){
+ // Check if the new salary is less than the maximum allowed salary.
+ if (newSalary < 20000) {
+ // Update the salary using the superclass's setSalary method.
super.setSalary(newSalary);
- }
- else{
- throw new IllegalArgumentException("You can not set a salary that exceed "+ maxSalary + " to "+super.getName());
+ } else {
+ // Throw an IllegalArgumentException if the new salary is too high.
+ throw new IllegalArgumentException("You cannot set a salary that exceeds " + maxSalary + " for " + super.getName());
}
}
-
-
}
From b7619684b7c33868871b7094a273d209550eb3a7 Mon Sep 17 00:00:00 2001
From: Motodies <39949690+Motodies@users.noreply.github.com>
Date: Sat, 29 Mar 2025 09:26:42 +0100
Subject: [PATCH 14/17] Some optimisation and commenting
---
.idea/workspace.xml | 14 ++++++++++----
src/Basics.java | 26 ++++++++++++--------------
2 files changed, 22 insertions(+), 18 deletions(-)
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index dde1643..4f6f2fd 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -7,9 +7,6 @@
-
-
-
@@ -45,6 +42,7 @@
1743209203969
-
+
+
+ 1743236162223
+
+
+
+ 1743236162223
+
+
diff --git a/src/Basics.java b/src/Basics.java
index 792d569..3f13ebc 100644
--- a/src/Basics.java
+++ b/src/Basics.java
@@ -1,24 +1,26 @@
public class Basics {
public static void main(String[] args) {
+ // Define an array of integers.
+ int[] array = {12, 90, 56, 1, 2, 78};
+
// Call methods to calculate the difference between the largest and smallest element,
// and to find the two smallest elements in the array.
- diffLargestAndSmallest();
- firstAndSecondSmallest();
+ diffLargestAndSmallest(array);
+ firstAndSecondSmallest(array);
}
/**
* Method to calculate the difference between the largest and smallest element in an array.
+ * @param array The array of integers.
*/
- public static void diffLargestAndSmallest() {
- // Initialize the array with values.
- int[] array = {12, 34, 56, 69, 2, 78};
-
+ public static void diffLargestAndSmallest(int[] array) {
// Initialize variables to store the smallest and largest elements.
int smallest = array[0];
int largest = array[0];
- // Iterate through each element in the array.
- if(array.length>0){
+ // Check if the array is not empty.
+ if (array.length > 0) {
+ // Iterate through each element in the array.
for (int j : array) {
// Update the smallest element if the current element is smaller.
if (smallest > j) {
@@ -29,10 +31,8 @@ public static void diffLargestAndSmallest() {
largest = j;
}
}
-
}
-
// Calculate the difference between the largest and smallest elements.
int diff = largest - smallest;
@@ -42,11 +42,9 @@ public static void diffLargestAndSmallest() {
/**
* Method to find the two smallest elements in an array.
+ * @param array The array of integers.
*/
- public static void firstAndSecondSmallest() {
- // Initialize the array with values.
- int[] array = {12, 34, 56, 69, 2, 78, 8};
-
+ public static void firstAndSecondSmallest(int[] array) {
// Check that the array contains at least two elements.
if (array.length < 2) {
System.out.println("Array must have at least two elements.");
From 4d29305c0e87593a26b8bbe39e892af13484189e Mon Sep 17 00:00:00 2001
From: Motodies <39949690+Motodies@users.noreply.github.com>
Date: Sat, 29 Mar 2025 11:03:49 +0100
Subject: [PATCH 15/17] Change variable "array" name to "list"
---
.idea/workspace.xml | 17 ++++++----
out/production/lab-java-basics/Basics.class | Bin 0 -> 1979 bytes
out/production/lab-java-basics/Company.class | Bin 0 -> 1108 bytes
out/production/lab-java-basics/Employee.class | Bin 0 -> 1538 bytes
out/production/lab-java-basics/Intern.class | Bin 0 -> 1266 bytes
src/Basics.java | 30 +++++++++---------
6 files changed, 26 insertions(+), 21 deletions(-)
create mode 100644 out/production/lab-java-basics/Basics.class
create mode 100644 out/production/lab-java-basics/Company.class
create mode 100644 out/production/lab-java-basics/Employee.class
create mode 100644 out/production/lab-java-basics/Intern.class
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 4f6f2fd..43b3d25 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,10 +4,7 @@
-
-
-
-
+
@@ -48,7 +45,7 @@
"RunOnceActivity.git.unshallow": "true",
"git-widget-placeholder": "main",
"kotlin-language-version-configured": "true",
- "last_opened_file_path": "C:/Users/smlco/Documents/study/java/lab-java-basics/src",
+ "last_opened_file_path": "C:/Users/smlco/Documents/study/java/Week-3-Day-1",
"project.structure.last.edited": "Modules",
"project.structure.proportion": "0.0",
"project.structure.side.proportion": "0.0"
@@ -172,7 +169,15 @@
1743236162223
-
+
+
+ 1743236802973
+
+
+
+ 1743236802973
+
+
diff --git a/out/production/lab-java-basics/Basics.class b/out/production/lab-java-basics/Basics.class
new file mode 100644
index 0000000000000000000000000000000000000000..bfba1159b65bebf5a8d8f5c2c5a080fe1fa5547d
GIT binary patch
literal 1979
zcmaKt-%cAx6vn^7_O5XZI3^~4An7I{)X)Z+HgyvIqyYkr!Qiw;RBn3F!3?lq@1or$
zQKU+}=|%enz3N3&Dc9{qTA_*u=o|E=&rwxT-EVeHF#%P}j%UuEnK|F@oEd)qXa4}e
zEIv)412GfvG!ifbGTZX09IH!bbF93!t!jaQF=;z?a9<#nA6`u%iB1!#G|p&uV@CRR
z%@^ofw>LIQ(%V#iFzu{Y8nRwzSG#wm(XD;^Hf%5YsA}$!OD8foYa*LQFU}ncpz_=g
zRD=7vdkiC23PZEqvB#e61eL&3vN4gRioP_?$lA`5+zsO~ahvmPn!{>1
ztP_E5|5#NBq$=*7S5x!0R(2)|epHiVjm)@i;0K=ET~fi8yY443El^q6QkLFRdCI9N
zYfS~ulyaqOd07iwj~KsiFRhkiB<>NzsF(#8XH)H&k
zs>U+uay6d$yj)FW?v|@Yyj(RCw49u(rSLL!&Q#b4m+
z&0J!%VD#sVA7SK-$$^~lLU*RVNr;!tKL`5P@BfUR{(;N;$N{f#QHL7~)fUjjem5bV
z#SLU>%TZ$=9^wKPa1l!wK!tbMDs5lT<4dY{=%wl0rp$+&a|`cN&{Zts1KL2Z1$;=G
zpx-~(Nn5ALuR!(Dn@M!dUpfiS1)B+6nex5`h
UgzZe&KIEc6iq<7=^a(Eh3wEWvdH?_b
literal 0
HcmV?d00001
diff --git a/out/production/lab-java-basics/Company.class b/out/production/lab-java-basics/Company.class
new file mode 100644
index 0000000000000000000000000000000000000000..eed55f5e4a65ce752d638c48dbac43adec114fe2
GIT binary patch
literal 1108
zcmZuvOHUI~7(KV0cBZ9;nU+$X3chH0RjZ-`RKuBnGKq)OBk^RYim;K4;o$!;}zV2$i_L
z&TXrqh7m%mL)ylWOcnppmh6URE>F(QrOOf&1~I?4rE8`tAb$S=wmYszKVUHIka}>eQ^v11i#{QdMqDh9M#y!4QT?x@~y^7}`_mimvf|&)I$6B2OhoY$
zk|=1CGYlLP+P
zUZGuvW=3;hXb0@I8@@`T69#?bG)BAwxQ6Sr3*iPP2%%(VP`iSJeV4-@Ar^=I?-6~bW
zgzQA%4bF50wvpP#$a8_cI{4{0;)ml%4sA3Fq*p`|5>l=cVcbItmdGO=Q9MN}UeLKs
z$asr5_L0CBn!izo<77W^?bG>5Oi>HSH{2v%$L+7Ug=unihIUE#4)6g15w}I;>1EW5
NU+AUq9SZwU_ygwv>RbQ-
literal 0
HcmV?d00001
diff --git a/out/production/lab-java-basics/Employee.class b/out/production/lab-java-basics/Employee.class
new file mode 100644
index 0000000000000000000000000000000000000000..980fa45918142590c411462f5656d4a342be87ee
GIT binary patch
literal 1538
zcmaKsTTdE66vzJqxC?agf{OK4X~hbwmELctNlR)_KJ;nC39c@?WOp?oO}|G!
zL?7Curil;z0R2!+&+INrVQt9loS8Xu&Tr0thTnfKegUZBWg0QWRU|ZwKw%g^=4ZTY
za;sH-e{d|C9)q%JScbRF5HFVYQ%EAEBCX*DG=}7xcE_~4LNFvO-li^FzlzZC9K&i=
zt
zK6RR6$B^im9^Hl%fRub~+n(z=yz@?YNA{tc#65=Pp4TTS*VZaqUC)ywTWmcasIbL8
zk0~gpaUTyDf+~;YkhuoP!ihgN~QtU~JK2NiHupbLpq!C5(^D^I(nI+AXd}qW&2fbh?GWx6fdRO^rZr_QW|O*Y7-ZvA_jFT_fciTD#uasi>PCbdU@S8sIB8MjnZU2
J!85$T>|YHI9jO2S
literal 0
HcmV?d00001
diff --git a/out/production/lab-java-basics/Intern.class b/out/production/lab-java-basics/Intern.class
new file mode 100644
index 0000000000000000000000000000000000000000..e933c16161ae2b50a23081c84e06adc7a95470cb
GIT binary patch
literal 1266
zcmaKrU2hUm5Qg6a*yXEIkhWGz-PX2Js%@>`QcaY!k%Zy}4W{wx6ppZEIZJjAwfzVF
z1h0*W*Itp-MDP7k>MRQu1IlK1=L|FNJagvkkDuq?0OavB3?KX&0#RJT1VeDQ)i$j&
zAs8lh3~8um46~WyF+bs(CYSZiva$_X&lL)56%9d(Do7=4sUgg;bP-lCO;P9ObGzPY
z38{8ZtD>z8OD3plG>S=FCfycqio7MOT)j3_gDgjJsT_vYF%{QFA;Jh@$_0-zOpi;c
zxZPceB8h2+kRw!?o7_HQ2xN%g{c|>otC(ZZ>Oz%xi`q_R##Ey07C#+ivjW590Jp-;
zj_?B|on-S?jU-}4LyA(TbtLQqeq@p-QM9VutZ>_K*L`O|H4JJtSoF3qNBOdckQi;1
z!O!dNP@H}TlV!!L&3)ePiD_74n7Y`0Z%Pc&PP@jH7=VYQcsH=aWvgRX#h&5vMLdKJ
zSAm3HSe9~>&D;AzHLRKw#1_NWq1Dl=TuMvnw3Ry7Jr-RxxY7kpSkxSSdy9VhTg%p2
zYy#V1+{HZ&_uY{{U|7CDG~|iZ6#et$oq|1HRhB!R55vRk2YM(kxvZJOSuR>uv(wIv
zZq$(Huf&71wipxsW+?vE(Xpti-0=AO5_xW#WkU%XQM4eXu=6H&9N}nq%&;=j(>PQO
zl)Ui&P#Uk-7Z#z>;RG12(Uqe2Jgt04)6Lv3m7WXad5-{HKsviVpYDRC<0btQ;$IOu
zTt7zy=py$03kCRbot}waaFE0!xJ(n7M+`dovz`c*U7{7q;Rcqeglnx(c^4&(RkHlJ
zNp>9U7bOQYXc{ui4P+!T-KT0&n47YgBAkziWK&%vJ|pR3WxJU9Cs~rnW{7Eys8T($
t8BgdB*&^0^+u>3K;EPRBsas_Ga2p%+4ids0x;OEVR$;Op;R$vy_Zt!tFKGY(
literal 0
HcmV?d00001
diff --git a/src/Basics.java b/src/Basics.java
index 3f13ebc..fa90283 100644
--- a/src/Basics.java
+++ b/src/Basics.java
@@ -1,27 +1,27 @@
public class Basics {
public static void main(String[] args) {
- // Define an array of integers.
- int[] array = {12, 90, 56, 1, 2, 78};
+ // Define a list of integers.
+ int[] list = {12, 90, 56, 1, 2, 78};
// Call methods to calculate the difference between the largest and smallest element,
- // and to find the two smallest elements in the array.
- diffLargestAndSmallest(array);
- firstAndSecondSmallest(array);
+ // and to find the two smallest elements in the list.
+ diffLargestAndSmallest(list);
+ firstAndSecondSmallest(list);
}
/**
* Method to calculate the difference between the largest and smallest element in an array.
- * @param array The array of integers.
+ * @param list The list of integers.
*/
- public static void diffLargestAndSmallest(int[] array) {
+ public static void diffLargestAndSmallest(int[] list) {
// Initialize variables to store the smallest and largest elements.
- int smallest = array[0];
- int largest = array[0];
+ int smallest = list[0];
+ int largest = list[0];
- // Check if the array is not empty.
- if (array.length > 0) {
- // Iterate through each element in the array.
- for (int j : array) {
+ // Check if the list is not empty.
+ if (list.length > 0) {
+ // Iterate through each element in the list.
+ for (int j : list) {
// Update the smallest element if the current element is smaller.
if (smallest > j) {
smallest = j;
@@ -37,7 +37,7 @@ public static void diffLargestAndSmallest(int[] array) {
int diff = largest - smallest;
// Print the result.
- System.out.println("The difference between the smallest (" + smallest + ") and largest (" + largest + ") integer of this array is: " + diff);
+ System.out.println("The difference between the smallest (" + smallest + ") and largest (" + largest + ") integer of this list is: " + diff);
}
/**
@@ -62,7 +62,7 @@ public static void firstAndSecondSmallest(int[] array) {
secondSmallest = firstSmallest;
firstSmallest = i;
}
- // Update the second smallest element if the current element is smaller than the second smallest but larger than the first smallest.
+ // Update the second-smallest element if the current element is smaller than the second smallest but larger than the first smallest.
else if (secondSmallest > i) {
secondSmallest = i;
}
From 0ae30ca60894bf38d008f148c0bc9403f178881e Mon Sep 17 00:00:00 2001
From: Motodies <39949690+Motodies@users.noreply.github.com>
Date: Sat, 29 Mar 2025 11:04:38 +0100
Subject: [PATCH 16/17] Change variable "array" name to "list"
---
out/production/lab-java-basics/Basics.class | Bin 1979 -> 0 bytes
out/production/lab-java-basics/Company.class | Bin 1108 -> 0 bytes
out/production/lab-java-basics/Employee.class | Bin 1538 -> 0 bytes
out/production/lab-java-basics/Intern.class | Bin 1266 -> 0 bytes
4 files changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 out/production/lab-java-basics/Basics.class
delete mode 100644 out/production/lab-java-basics/Company.class
delete mode 100644 out/production/lab-java-basics/Employee.class
delete mode 100644 out/production/lab-java-basics/Intern.class
diff --git a/out/production/lab-java-basics/Basics.class b/out/production/lab-java-basics/Basics.class
deleted file mode 100644
index bfba1159b65bebf5a8d8f5c2c5a080fe1fa5547d..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 1979
zcmaKt-%cAx6vn^7_O5XZI3^~4An7I{)X)Z+HgyvIqyYkr!Qiw;RBn3F!3?lq@1or$
zQKU+}=|%enz3N3&Dc9{qTA_*u=o|E=&rwxT-EVeHF#%P}j%UuEnK|F@oEd)qXa4}e
zEIv)412GfvG!ifbGTZX09IH!bbF93!t!jaQF=;z?a9<#nA6`u%iB1!#G|p&uV@CRR
z%@^ofw>LIQ(%V#iFzu{Y8nRwzSG#wm(XD;^Hf%5YsA}$!OD8foYa*LQFU}ncpz_=g
zRD=7vdkiC23PZEqvB#e61eL&3vN4gRioP_?$lA`5+zsO~ahvmPn!{>1
ztP_E5|5#NBq$=*7S5x!0R(2)|epHiVjm)@i;0K=ET~fi8yY443El^q6QkLFRdCI9N
zYfS~ulyaqOd07iwj~KsiFRhkiB<>NzsF(#8XH)H&k
zs>U+uay6d$yj)FW?v|@Yyj(RCw49u(rSLL!&Q#b4m+
z&0J!%VD#sVA7SK-$$^~lLU*RVNr;!tKL`5P@BfUR{(;N;$N{f#QHL7~)fUjjem5bV
z#SLU>%TZ$=9^wKPa1l!wK!tbMDs5lT<4dY{=%wl0rp$+&a|`cN&{Zts1KL2Z1$;=G
zpx-~(Nn5ALuR!(Dn@M!dUpfiS1)B+6nex5`h
UgzZe&KIEc6iq<7=^a(Eh3wEWvdH?_b
diff --git a/out/production/lab-java-basics/Company.class b/out/production/lab-java-basics/Company.class
deleted file mode 100644
index eed55f5e4a65ce752d638c48dbac43adec114fe2..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 1108
zcmZuvOHUI~7(KV0cBZ9;nU+$X3chH0RjZ-`RKuBnGKq)OBk^RYim;K4;o$!;}zV2$i_L
z&TXrqh7m%mL)ylWOcnppmh6URE>F(QrOOf&1~I?4rE8`tAb$S=wmYszKVUHIka}>eQ^v11i#{QdMqDh9M#y!4QT?x@~y^7}`_mimvf|&)I$6B2OhoY$
zk|=1CGYlLP+P
zUZGuvW=3;hXb0@I8@@`T69#?bG)BAwxQ6Sr3*iPP2%%(VP`iSJeV4-@Ar^=I?-6~bW
zgzQA%4bF50wvpP#$a8_cI{4{0;)ml%4sA3Fq*p`|5>l=cVcbItmdGO=Q9MN}UeLKs
z$asr5_L0CBn!izo<77W^?bG>5Oi>HSH{2v%$L+7Ug=unihIUE#4)6g15w}I;>1EW5
NU+AUq9SZwU_ygwv>RbQ-
diff --git a/out/production/lab-java-basics/Employee.class b/out/production/lab-java-basics/Employee.class
deleted file mode 100644
index 980fa45918142590c411462f5656d4a342be87ee..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 1538
zcmaKsTTdE66vzJqxC?agf{OK4X~hbwmELctNlR)_KJ;nC39c@?WOp?oO}|G!
zL?7Curil;z0R2!+&+INrVQt9loS8Xu&Tr0thTnfKegUZBWg0QWRU|ZwKw%g^=4ZTY
za;sH-e{d|C9)q%JScbRF5HFVYQ%EAEBCX*DG=}7xcE_~4LNFvO-li^FzlzZC9K&i=
zt
zK6RR6$B^im9^Hl%fRub~+n(z=yz@?YNA{tc#65=Pp4TTS*VZaqUC)ywTWmcasIbL8
zk0~gpaUTyDf+~;YkhuoP!ihgN~QtU~JK2NiHupbLpq!C5(^D^I(nI+AXd}qW&2fbh?GWx6fdRO^rZr_QW|O*Y7-ZvA_jFT_fciTD#uasi>PCbdU@S8sIB8MjnZU2
J!85$T>|YHI9jO2S
diff --git a/out/production/lab-java-basics/Intern.class b/out/production/lab-java-basics/Intern.class
deleted file mode 100644
index e933c16161ae2b50a23081c84e06adc7a95470cb..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 1266
zcmaKrU2hUm5Qg6a*yXEIkhWGz-PX2Js%@>`QcaY!k%Zy}4W{wx6ppZEIZJjAwfzVF
z1h0*W*Itp-MDP7k>MRQu1IlK1=L|FNJagvkkDuq?0OavB3?KX&0#RJT1VeDQ)i$j&
zAs8lh3~8um46~WyF+bs(CYSZiva$_X&lL)56%9d(Do7=4sUgg;bP-lCO;P9ObGzPY
z38{8ZtD>z8OD3plG>S=FCfycqio7MOT)j3_gDgjJsT_vYF%{QFA;Jh@$_0-zOpi;c
zxZPceB8h2+kRw!?o7_HQ2xN%g{c|>otC(ZZ>Oz%xi`q_R##Ey07C#+ivjW590Jp-;
zj_?B|on-S?jU-}4LyA(TbtLQqeq@p-QM9VutZ>_K*L`O|H4JJtSoF3qNBOdckQi;1
z!O!dNP@H}TlV!!L&3)ePiD_74n7Y`0Z%Pc&PP@jH7=VYQcsH=aWvgRX#h&5vMLdKJ
zSAm3HSe9~>&D;AzHLRKw#1_NWq1Dl=TuMvnw3Ry7Jr-RxxY7kpSkxSSdy9VhTg%p2
zYy#V1+{HZ&_uY{{U|7CDG~|iZ6#et$oq|1HRhB!R55vRk2YM(kxvZJOSuR>uv(wIv
zZq$(Huf&71wipxsW+?vE(Xpti-0=AO5_xW#WkU%XQM4eXu=6H&9N}nq%&;=j(>PQO
zl)Ui&P#Uk-7Z#z>;RG12(Uqe2Jgt04)6Lv3m7WXad5-{HKsviVpYDRC<0btQ;$IOu
zTt7zy=py$03kCRbot}waaFE0!xJ(n7M+`dovz`c*U7{7q;Rcqeglnx(c^4&(RkHlJ
zNp>9U7bOQYXc{ui4P+!T-KT0&n47YgBAkziWK&%vJ|pR3WxJU9Cs~rnW{7Eys8T($
t8BgdB*&^0^+u>3K;EPRBsas_Ga2p%+4ids0x;OEVR$;Op;R$vy_Zt!tFKGY(
From c598901f0024d1adbdba006dc9705bbdf2a4a884 Mon Sep 17 00:00:00 2001
From: Motodies <39949690+Motodies@users.noreply.github.com>
Date: Sat, 29 Mar 2025 11:09:55 +0100
Subject: [PATCH 17/17] Change variable "array" name to "list"
---
.idea/workspace.xml | 71 ++++++++++++++++++++++++++++-----------------
src/Basics.java | 18 ++++++------
2 files changed, 54 insertions(+), 35 deletions(-)
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 43b3d25..ce2d5ab 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,7 +4,9 @@
-
+
+
+
@@ -13,18 +15,18 @@
- {
+ "lastFilter": {
+ "state": "OPEN",
+ "assignee": "smlcolinDEV"
}
-}]]>
-
+ {
+ "selectedUrlAndAccountId": {
+ "url": "https://github.com/smlcolinDEV/lab-java-basics.git",
+ "accountId": "b480d773-6a55-4125-9d5c-0e9a6f8f7126"
}
-}]]>
+}
@@ -37,20 +39,20 @@
- {
+ "keyToString": {
+ "Application.Basics.executor": "Run",
+ "Application.Company.executor": "Run",
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "RunOnceActivity.git.unshallow": "true",
+ "git-widget-placeholder": "main",
+ "kotlin-language-version-configured": "true",
+ "last_opened_file_path": "C:/Users/smlco/Documents/study/java/Week-3-Day-1",
+ "project.structure.last.edited": "Modules",
+ "project.structure.proportion": "0.0",
+ "project.structure.side.proportion": "0.0"
}
-}]]>
+}
@@ -177,12 +179,29 @@
1743236802973
-
+
+
+ 1743242637960
+
+
+
+ 1743242637960
+
+
+
+ 1743242680871
+
+
+
+ 1743242680871
+
+
-
+
+
\ No newline at end of file
diff --git a/src/Basics.java b/src/Basics.java
index fa90283..894f2dd 100644
--- a/src/Basics.java
+++ b/src/Basics.java
@@ -1,6 +1,6 @@
public class Basics {
public static void main(String[] args) {
- // Define a list of integers.
+ // Declare and initialize a list of integers.
int[] list = {12, 90, 56, 1, 2, 78};
// Call methods to calculate the difference between the largest and smallest element,
@@ -11,14 +11,14 @@ public static void main(String[] args) {
/**
* Method to calculate the difference between the largest and smallest element in an array.
- * @param list The list of integers.
+ * @param list The array of integers.
*/
public static void diffLargestAndSmallest(int[] list) {
// Initialize variables to store the smallest and largest elements.
int smallest = list[0];
int largest = list[0];
- // Check if the list is not empty.
+ // Check that the list is not empty.
if (list.length > 0) {
// Iterate through each element in the list.
for (int j : list) {
@@ -37,16 +37,16 @@ public static void diffLargestAndSmallest(int[] list) {
int diff = largest - smallest;
// Print the result.
- System.out.println("The difference between the smallest (" + smallest + ") and largest (" + largest + ") integer of this list is: " + diff);
+ System.out.println("The difference between the smallest (" + smallest + ") and largest (" + largest + ") integer in this list is: " + diff);
}
/**
* Method to find the two smallest elements in an array.
- * @param array The array of integers.
+ * @param list The array of integers.
*/
- public static void firstAndSecondSmallest(int[] array) {
- // Check that the array contains at least two elements.
- if (array.length < 2) {
+ public static void firstAndSecondSmallest(int[] list) {
+ // Check that the list contains at least two elements.
+ if (list.length < 2) {
System.out.println("Array must have at least two elements.");
return;
}
@@ -56,7 +56,7 @@ public static void firstAndSecondSmallest(int[] array) {
int secondSmallest = Integer.MAX_VALUE;
// Iterate through each element in the array.
- for (int i : array) {
+ for (int i : list) {
// Update the first smallest element if the current element is smaller.
if (firstSmallest > i) {
secondSmallest = firstSmallest;