From f9516e9393b7df251cde76937ed79c78b6d9329f Mon Sep 17 00:00:00 2001 From: Frangithub90 Date: Wed, 8 Apr 2026 19:53:40 +0200 Subject: [PATCH 1/3] Lab Java Interfaces & Abstract Classes WEEK3. COMPLETED --- .idea/.gitignore | 10 ++++ ...b-java-interfaces-and-abstract-classes.iml | 11 ++++ .idea/misc.xml | 6 ++ .idea/modules.xml | 8 +++ .idea/vcs.xml | 6 ++ .vscode/extensions.json | 5 ++ README.md | 27 +++++++-- .../BigDecimalOperations.class | Bin 0 -> 926 bytes .../BigDecimalOperationsApplication.class | Bin 0 -> 2184 bytes .../AppCarInventorySystem.class | Bin 0 -> 1925 bytes .../CarInventorySystem/Car.class | Bin 0 -> 1874 bytes .../CarInventorySystem/Sedan.class | Bin 0 -> 450 bytes .../CarInventorySystem/Truck.class | Bin 0 -> 1516 bytes .../CarInventorySystem/UtilityVehicle.class | Bin 0 -> 1525 bytes .../IntListInterface/IntArrayList.class | Bin 0 -> 1504 bytes .../IntListInterface/IntList.class | Bin 0 -> 154 bytes .../IntListInterface/IntListTest.class | Bin 0 -> 1754 bytes .../IntListInterface/IntVector.class | Bin 0 -> 1484 bytes .../AppVideoStreamingService.class | Bin 0 -> 1703 bytes .../VideoStreamingService/Movie.class | Bin 0 -> 1113 bytes .../VideoStreamingService/TvSeries.class | Bin 0 -> 1238 bytes .../VideoStreamingService/Video.class | Bin 0 -> 644 bytes .../BigDecimalOperations.java | 16 ++++++ .../BigDecimalOperationsApplication.java | 25 ++++++++ .../AppCarInventorySystem.java | 27 +++++++++ src/CarInventorySystem/Car.java | 54 ++++++++++++++++++ src/CarInventorySystem/Sedan.java | 8 +++ src/CarInventorySystem/Truck.java | 25 ++++++++ src/CarInventorySystem/UtilityVehicle.java | 26 +++++++++ src/IntListInterface/IntArrayList.java | 33 +++++++++++ src/IntListInterface/IntList.java | 6 ++ src/IntListInterface/IntListTest.java | 38 ++++++++++++ src/IntListInterface/IntVector.java | 31 ++++++++++ .../AppVideoStreamingService.java | 25 ++++++++ src/VideoStreamingService/Movie.java | 17 ++++++ src/VideoStreamingService/TvSeries.java | 20 +++++++ src/VideoStreamingService/Video.java | 21 +++++++ 37 files changed, 439 insertions(+), 6 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/lab-java-interfaces-and-abstract-classes.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 .vscode/extensions.json create mode 100644 out/production/lab-java-interfaces-and-abstract-classes/BigDecimalOperations/BigDecimalOperations.class create mode 100644 out/production/lab-java-interfaces-and-abstract-classes/BigDecimalOperations/BigDecimalOperationsApplication.class create mode 100644 out/production/lab-java-interfaces-and-abstract-classes/CarInventorySystem/AppCarInventorySystem.class create mode 100644 out/production/lab-java-interfaces-and-abstract-classes/CarInventorySystem/Car.class create mode 100644 out/production/lab-java-interfaces-and-abstract-classes/CarInventorySystem/Sedan.class create mode 100644 out/production/lab-java-interfaces-and-abstract-classes/CarInventorySystem/Truck.class create mode 100644 out/production/lab-java-interfaces-and-abstract-classes/CarInventorySystem/UtilityVehicle.class create mode 100644 out/production/lab-java-interfaces-and-abstract-classes/IntListInterface/IntArrayList.class create mode 100644 out/production/lab-java-interfaces-and-abstract-classes/IntListInterface/IntList.class create mode 100644 out/production/lab-java-interfaces-and-abstract-classes/IntListInterface/IntListTest.class create mode 100644 out/production/lab-java-interfaces-and-abstract-classes/IntListInterface/IntVector.class create mode 100644 out/production/lab-java-interfaces-and-abstract-classes/VideoStreamingService/AppVideoStreamingService.class create mode 100644 out/production/lab-java-interfaces-and-abstract-classes/VideoStreamingService/Movie.class create mode 100644 out/production/lab-java-interfaces-and-abstract-classes/VideoStreamingService/TvSeries.class create mode 100644 out/production/lab-java-interfaces-and-abstract-classes/VideoStreamingService/Video.class create mode 100644 src/BigDecimalOperations/BigDecimalOperations.java create mode 100644 src/BigDecimalOperations/BigDecimalOperationsApplication.java create mode 100644 src/CarInventorySystem/AppCarInventorySystem.java create mode 100644 src/CarInventorySystem/Car.java create mode 100644 src/CarInventorySystem/Sedan.java create mode 100644 src/CarInventorySystem/Truck.java create mode 100644 src/CarInventorySystem/UtilityVehicle.java create mode 100644 src/IntListInterface/IntArrayList.java create mode 100644 src/IntListInterface/IntList.java create mode 100644 src/IntListInterface/IntListTest.java create mode 100644 src/IntListInterface/IntVector.java create mode 100644 src/VideoStreamingService/AppVideoStreamingService.java create mode 100644 src/VideoStreamingService/Movie.java create mode 100644 src/VideoStreamingService/TvSeries.java create mode 100644 src/VideoStreamingService/Video.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-java-interfaces-and-abstract-classes.iml b/.idea/lab-java-interfaces-and-abstract-classes.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/.idea/lab-java-interfaces-and-abstract-classes.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..4eb4f51 --- /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..ff55171 --- /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..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..309baca --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "vmware.vscode-boot-dev-pack" + ] +} \ No newline at end of file diff --git a/README.md b/README.md index ce069b6..80df066 100644 --- a/README.md +++ b/README.md @@ -30,18 +30,18 @@ Once you finish the assignment, submit a URL link to your repository or your pul
-### Car Inventory System +### CarInventorySystem.Car Inventory System -1. Suppose you are building a car inventory system. All cars have a `vinNumber`, `make`, `model` and `mileage`. But no car is just a car. Each car is either a `Sedan`, a `UtilityVehicle` or a `Truck`. -2. Create an abstract class named `Car` and define the following properties and behaviors: +1. Suppose you are building a car inventory system. All cars have a `vinNumber`, `make`, `model` and `mileage`. But no car is just a car. Each car is either a `CarInventorySystem.Sedan`, a `CarInventorySystem.UtilityVehicle` or a `CarInventorySystem.Truck`. +2. Create an abstract class named `CarInventorySystem.Car` and define the following properties and behaviors: - `vinNumber`: a `String` representing the VIN number of the car - `make`: a `String` representing the make of the car - `model`: a `String` representing the model of the car - `mileage`: an `int` representing the mileage of the car - `getInfo()`: a method that returns a `String` containing all of the car's properties in a readable format -3. Create three classes that extend `Car`: `Sedan`, `UtilityVehicle` and `Truck`. -4. `UtilityVehicle` objects should have an additional `fourWheelDrive` property, a `boolean` that represents whether the vehicle has four-wheel drive. -5. `Truck` objects should have an additional `towingCapacity` property, a `double` that represents the towing capacity of the truck. +3. Create three classes that extend `CarInventorySystem.Car`: `CarInventorySystem.Sedan`, `CarInventorySystem.UtilityVehicle` and `CarInventorySystem.Truck`. +4. `CarInventorySystem.UtilityVehicle` objects should have an additional `fourWheelDrive` property, a `boolean` that represents whether the vehicle has four-wheel drive. +5. `CarInventorySystem.Truck` objects should have an additional `towingCapacity` property, a `double` that represents the towing capacity of the truck.
@@ -68,6 +68,21 @@ Once you finish the assignment, submit a URL link to your repository or your pul 4. `IntVector` should store numbers in an array with a length of 20 by default. When the `add` method is called, you must first determine if the array is full. If it is, create a new array that is double the size of the current array, move all elements over to the new array and add the new element. (For example, an array of length 10 would be increased to 20.) 5. In your `README.md`, include an example of when `IntArrayList` would be more efficient and when `IntVector` would be more efficient. +# IntList Implementation Analysis + +## Efficiency Comparison: IntArrayList vs. IntVector + +This project includes two implementations of the `IntList` interface, each with a different strategy for resizing its internal array when it reaches capacity. + +### When is `IntArrayList` more efficient? +`IntArrayList` grows by **50%** of its current size when full. +* **Best Use Case:** It is more efficient in terms of **Memory (RAM) consumption**. It is ideal when you have limited memory resources or when you expect the list to grow, but at a slow, gradual, or predictable pace. Because it doesn't request massive blocks of memory at once, it prevents memory waste. + +### When is `IntVector` more efficient? +`IntVector` grows by **100%** (it doubles its size) when full. +* **Best Use Case:** It is more efficient in terms of **Processing Speed (CPU)** when dealing with massive amounts of data. Resizing an array (creating a new one and copying all elements over) is a heavy operation. By doubling in size, `IntVector` performs this costly operation much less frequently than `IntArrayList`. It trades memory space for faster execution times when rapidly adding many elements. + +
## FAQs diff --git a/out/production/lab-java-interfaces-and-abstract-classes/BigDecimalOperations/BigDecimalOperations.class b/out/production/lab-java-interfaces-and-abstract-classes/BigDecimalOperations/BigDecimalOperations.class new file mode 100644 index 0000000000000000000000000000000000000000..1631d10b6bc2892cce2d0372813143aff3ecd387 GIT binary patch literal 926 zcmZ{j+iuf95QhJ0lDbKqw6rB8oX^+^s>O8?QXxbj8Hz~BE!xB@cPnR&9J{Z@;UY*} z@Blm%V%9DMfn!U%v$Heb&dkpK`1$QSfaiGFz#1wRsy1p^Cv2aJGvP%-hu+cTR8CXE z`eUV4`h-w%+;JTns9R{**n~}J=jJn!o_KHLOb1Gbui`)wtQUv=@cp|tgpOZsbI?Ew zTNbu$T)+-tZ)x^ag#$TNGZ7Is<}w{kMa0ZU&dXIS_pgnmcYeg4jf-d#HiI~uL~<;m zj9Hw^zy#2-(Zyv>Qp-@JywP!1uq<39xJ&ra2bqXe#d_|QDGAkQc_p@drRD2vHj&A( z-~b3ae#{AtMWW35Tv<&|)SS@w%V4D^91xm`Df)3d$WtS9o$@-k1CwDM1K(M>&2O3v zieL%5i9D0ZT#i(z4|R}VFkyey87r|xY5!mwqc}^Za;Qu#x@GC^n^wRrT;bj{Uj<~k zlgDek@^~hmYrU_a&n&FrI*(?XmAJv9eJ|1g{E+bUt!nC0e7LNE8} F{{n8+*E|3K literal 0 HcmV?d00001 diff --git a/out/production/lab-java-interfaces-and-abstract-classes/BigDecimalOperations/BigDecimalOperationsApplication.class b/out/production/lab-java-interfaces-and-abstract-classes/BigDecimalOperations/BigDecimalOperationsApplication.class new file mode 100644 index 0000000000000000000000000000000000000000..7673387f7e7f303634f9d0f41c03691053f4c71f GIT binary patch literal 2184 zcmbVNTT|Oc6#f5*iN2}&jtX|!jx=d$NJm)(EnOg`iXJf?G_87uET6b*-A^sZ)T&W8-ck!W3l%rN5#wYk%ZrL|^OG_*F? zWhe~e@x*F8aq=pV5ONKVGt5Q`r>3ipr5Vj+v@TVtWw2R>Fq>OonsamdDQ;WIUW;v^_smG5VD|j7m zNO&`Z%dUUZo_A+e8KjPDNH-LyxFX^05Z=MUSr0rYBzeH~t|))YusDd+4`MQU9=w7@ zT$2z9A&Mo2=xHR&9bs`tGYxwnyr+v49n0(*do?p_c6W8bFyGtpsf;9}*)Sz}IfNCg zGR(F4zQ~wHgFE*$r$sZ{;f7-~TpRSbmz!*W%Q9{-Ecb)xhBTK|cb@Sa|MI&cBhC<3 z27@2>gTIKIA-s!Q6nRS=2+I~#t!bo;y^4#CVf9&<{760xH4KK^F3>wf1K^yGe;~dj z!;K!kxLV3>q+Ecd?P5AtQG?*R7{k;-w`EX+#QLgRW=CQ(wPvcl($P+%6F}-#?@>t zlP{(U)u=BmqsFlQ0(RnRBwwoMDsJIa^BX1Cnpa3v4Sib_v6r=VQdvD)6QlTC!F_xo z;elKJUs9+}&sohlF!x2wZ)v~v*LlM+twV+%2fL&v=*MD{8+*F27Ye4i-|ZyNXMAAg zjAHGuBLc(+iz47W?3u`LU9W16plS={4MSKNo!hpsCG0RaQ09m?0fibLOgH~MSe=$NY z@aQi{_rqgPaIxUcUZGjhn@!TJ^c%wASO36kM6dsex9GcigzJF66pr=inopNWguVok zBfQs_df(@+&@z2K_ims20dY^gkCV^9MJPmPFiv;g1l>QAxPvM3JB&PCu{*?RViw=i zHTwhRJfurL8f=mTNc%f{f=>zS3@j9AHbjW326g@4;n(94KZl_Q8{QB27-vPLa zj}*Azmf-QB3tonSOSfUtZAlW+4Xe2;%M99v{vAzj9vz5Vrnv)TFc7lr^#}?Y8JRIW02hI zkqd6%{zC-{{34%WhRea^UPfuh*3DwrkeY{stUw`7bpiH%M#EicPB$I!h{(rUJ4XpW5YG)?P9O|yBy z^3Hum=T6N#_v8KMK*1SIi4>#%KgGqx5FO}Cl*Cl@;-!_PjEqYRO4c&ADtCBMqoa>8 zbj>>kugG{=a2Ab5Q)1sMgvZAxq8Ge#pU*WDlCeM=B9W=+Qf5uYRXV9FsZ|+E46al} zoNB^{S8{sxr~WV?9V=MZ$F-Zs0Wrbx#AkTPReCS5~yULJ`5x zy0A$5kiktlLbD0`cYW`>7BLB{6t#mw2%C^r1iE7 zad0}r#LW1UwOI*U48aZr%$LhYQ6h7}DrgM-N!`>|s@ofyo#7h>A!^dfb0f=bUCi5{ z$0_L*hOy*PSK*EUNMD|9u2YqP;H{%CL?}z7=Q$~5q?1dEA{=nLNI{1>*wZ3e)8fEB znTdCV%mN1ssF!z(7(29g=HEikl9%4J!}D7yUT!m>q^+u**W$Y1=y=DP&kH$Y6r1#h zi{=7dCU~hgXcnd~qi@$(1MJJ@@;3EiS@b6LzSagFyRZo%W0s>g*hAPak09k5 z=uVz}1SO~X)IN1URT~)ELBNGoLQmw>lj zD`YXPUQ{m+PJiJ!WHCdYX8o8uWI>UysEcZR(Ea;f=p8IGq|WUi$?!2w)8KW6?~z^k z3TxvJ@YVxt&`2%O_tU?B69jl52$-a@MX@q^aFWK;=%v@84<+>D9tOzQ5Wa>V-(na) zA%LIh{~^da1vlX;DsX5-)S!x5)6);QgS$jroo0ek83K8aM(-2S2iKqYM8Yu%sXyqk LW%z(l7e4$4NC@A~ literal 0 HcmV?d00001 diff --git a/out/production/lab-java-interfaces-and-abstract-classes/CarInventorySystem/Car.class b/out/production/lab-java-interfaces-and-abstract-classes/CarInventorySystem/Car.class new file mode 100644 index 0000000000000000000000000000000000000000..b0214429b3d346087c74e9e89b448eabb50685ff GIT binary patch literal 1874 zcmbW1-A>e66vzJ?W?C3KG7f@*3VxstqcVP;;{oNIIBJ|Y>IDWbyeh*MDxH>03ki4L z`3hbcJujdqk(iJiAHc`(-d8aGS6i83D8_ivy;oP)UhB8lM?Zht`UKz({?4HXy(Tgi zvM>}1&+T=);@aL)<yGzut+}8n7wc`Ob79NzmS)7wehUNQBh$23v?vZ(D2gK6^cS@&nu8XG zFsxuU9aq~+T0zx{br6OCw z4y&P*8%z?ekIo)Qx+(HRBATLQYMFUaMp906Kgz&XxUGUw8M3UiFThk-nze{D{;HU9dg%hNS7+S>dZxA7^B>? zy+v0C6LsHTSzDdi-3lF=9S0w8tm+i=rych3IL&kxD{)b^U3bn2wbZuedAe0~?I6&B z32IL7x>FjeiJJ;zKR4wh$M?#d;Ar)5j51s~#*}(w6r-IJ810-p?m2KAafItpzP+Gb zmiuV=BUJg^Cd~5rP2|fLHc==KWi~PRUv&1E*udbLV~l<1r_cS!W030zBaQLP)z}lp zahz{rFC;3Gghlv9<$r+QND`h5zn{R#gr>q>?6c($FyB+?fdn=pWibj8JIp3Q6i#6x zIXp{i31LLnXk*Lo5Db;Yp~%Bjr$OcL6O((-OmOr*INlbn@qQcgua z7DieAExOgCniCF^zYK?jX07zv$(sC_nllkSk6D@2pv-NGX Z*~g*|BkLbxhf!mNy4Z!w^*v?|dS4hBWkCP{ literal 0 HcmV?d00001 diff --git a/out/production/lab-java-interfaces-and-abstract-classes/CarInventorySystem/Truck.class b/out/production/lab-java-interfaces-and-abstract-classes/CarInventorySystem/Truck.class new file mode 100644 index 0000000000000000000000000000000000000000..d8db09817692c8461214db545f424b4c6b50ae64 GIT binary patch literal 1516 zcmbVM*>Vy=6g?eaSez`7NC<9;CI-lY`vNg8U`ncpK0x7vPaV>d3BwGXy2W6pb{g7_=3`GUO^lCQ;nx9iBG1RZEv-%dl$M|IrkZl^_BL`VrD`20BCR z7_M@wU9B^WNc#<4oa0SiHDs58r^= zPxy6S7fN?lM^xzoN@s5hQz>IQrVwWcDWzcwUK0$SM6$7^cJWA-^J&!%I4* zF~cy~AcCB2Rk?g=$Ssl_$t~$H6i=D4eEyiQ7_z6ouEOBWQOpdZMZ*$q{>psABu%7f zSGif?Eko`5O0V29D1vzLU!}@21UmU`appQMLOQQA==w(e;n3&*`OZ`X$s2CMV^9Gobl9G4AThHn4mF9MT0-xw~ l(7Wh>ck%w+9$f38uHy!+0lM)vjho2QE=1A_CGQcYeglnQYM1~3 literal 0 HcmV?d00001 diff --git a/out/production/lab-java-interfaces-and-abstract-classes/CarInventorySystem/UtilityVehicle.class b/out/production/lab-java-interfaces-and-abstract-classes/CarInventorySystem/UtilityVehicle.class new file mode 100644 index 0000000000000000000000000000000000000000..cbc6e8d909fa147ac91a538c1e8be56171a17e7d GIT binary patch literal 1525 zcmbVMTTc@~6#j-@wyX;+1&V+o2xwa_^@6t+@zP3cQuLu%lKQlipWo-#gkc(@RpK?HVseK5ZF|qzsBv!Q9HU79E34$CUqcuX2Cd3P$*^ASH8wes9EvAS zQ<3^n4TDl&A^kPI&LuXiAtteq#Oy6@O7OCVQH(LD5;RP%S1G11p2$ThT~{<*#RS7h zgIr{7tD=hyL)1ueg>DI#p>V?d4L+(4EU(^gb!F1uDRmm{)Hjk1XJ)LrjEmOo0XvoA;-Wz{%$?^;l!(Ba5R!VW1 zVZi0$$eHdA}ytQppX^Lc9;j844VeojvEXvlT0MBh(xWdtQ*SM(JTW$zT4D*NY zzaQ>@pngd+Rd#_~BtN-&{L*Z)-cXk|ax5IgeH9PzP{AWv_B6xHQQsR@)2{PQ`+J?R zs#oNlVR+YFw2q=j)NBGTm*|ago(c zvuFrTWz+JO#ht9FyDoPXJZ6|Zb*8hZDtN*$alR@&5#G5lMfa$Ot_!1?E;>nmk^{I# z^Cazrd}?ToBU31$+6g_J@k)tXfPV?oMB&Ln2?ItnbA5Cd#+=ghzZ64eSQ~JV2-X^LY$s@_7 z;Scb}Gc&xvJ1@*o%9Kud=NIwBa8?$!+h(vw(%rjv&$;*9-TmvIXDGVY$=Nvz^H?BZp!)Nf^3BSD zfhB>9!?bL#r5^A1qWuRue$Q)#w;nsH8@awWOPFN~1-v1!cp}@X?t6}mzHp;sT45x; zC=^&I+jgZfglk5D>m6;ISj4KO^27F4pn8 zEVw#~(N}WY9)bPOW$OYj2`rr@WM9Kf-EUE>>4xj6JH3-b72K7F9eQRPz9TyaGH~@c zab}`pmu0Rs&H@~CW}DrVtrj~`W(Jhpi-83un~`+dw`DhhOCKq=QAgSAqRSPAr@n6X z+jmnS%TbIfU^e|;;HX_!=aw7Y2U}WhO19(sQ5XfXds{`vek;s^c`%X@+LKjm!rEXfvC$)r|CwDWm>l9si5AGVW>g_l&Qjj7jQQMr0;8IK zg2`XvH5I;Rxd!0nKvWA8$nls~>9L5RXD?%eUx7_*C8#|zr0CnI{)$OH#)}`3tH#E+ zbI7%S!+AZZ-sAL_nXkxJ*w=h%4Ed&rKaFLwT_%U-Tj*mZd_+f$6$!i@uN2EP-@&^{ z3T>vVQz#XFz`26X<0s7jfyH~V{S0~FDOUc}X%x189&k@F2hC*Zi-18x-qL`#g!cx# zB(ZWN;*FIMJFH#nmA~}ebMubIPj99*|L-VPH>vKc!me<^D$ZjKODM*K#W;!lfH05u n@d4q-FozGBTAKflNRh(F_=Mjq=dSX(f*p=bT6Ny(pCkV-L4->A literal 0 HcmV?d00001 diff --git a/out/production/lab-java-interfaces-and-abstract-classes/IntListInterface/IntList.class b/out/production/lab-java-interfaces-and-abstract-classes/IntListInterface/IntList.class new file mode 100644 index 0000000000000000000000000000000000000000..85a0482704bf29585f286a29bf06ae1235456716 GIT binary patch literal 154 zcmX^0Z`VEs1_oCKZgvJHMg|Gbyb_;-7EI}tIHiD_fQtjP&bZU*)5hK=BDUm_Hca#0 zAJON&^tpW~EuG;9^mp_J@Z9O`tfd*mSf#bR`|W<$b5@`B*T0@V1F(g*jSR9Dat=;l zLZI+SK9;q<^!95H_8zIO7MR#{Jy+il$X2Qy8+lAxupOKi*GSPX)VjuTM>}<#%PjBLmm$V`WYsxWuyDO3Q2b8XR?I9Y~jF zJX`r<9C5WnyA1Z3XC}ogAY6{7fa4|_id_D+C<{)twd@}5$YBh0lCcp_0lV!V1zol6 z8d`-IxdD2`vH5mcZ(ZFUj>D`-iF)byM^fx20+NV}Wmy{T4e$_3lcq*H__c%l8kDhV}6iOK4sS z+&vzu6!+wzM&EWl**I~EhV1v-u2wuer|EerX!KXU&WrF<3}sHv6MU>h8Veh!(`K8SEl%@{m<+Z%KVZ6e=0}|U1*OlQ;M~3J=3?R6 zwF1<7^RQ`W1^W?HXE+ukVCdLxEtdPqEqFW)Cwg2RD>(yMcxJ{ZFH1H8+ Uo~-V0Y+;8xo2&bHh)*&94|?&Nd;kCd literal 0 HcmV?d00001 diff --git a/out/production/lab-java-interfaces-and-abstract-classes/IntListInterface/IntVector.class b/out/production/lab-java-interfaces-and-abstract-classes/IntListInterface/IntVector.class new file mode 100644 index 0000000000000000000000000000000000000000..5b48e94d0f8b6fe27c11e58dbe9038b19d444131 GIT binary patch literal 1484 zcmaJ>U31$+6g_J@QKBkwVwyCr(~y3c+M$VOa@C9-oR;+genaeYB%d01Iq#z$E7%a zS3TJs#=8%k#3oiOlyO$z%%SY5X5hOr{?dyNIE!NG$C1Et&2j3j zF;7 zwu52lsvS=kHa{|cQwvS8wu2y!;!qCmsQ4i0Ml<+SU@@`s>bkhHt}!_&PJ>Qd!)FGr zYbQS!xHPuP^B)I2)kqyn&E1ju^`hQCOzNE-Ou24LzuQ;QrB)F1hJ&pM4>Ic~BCjOg zI~u4Hjz5?fpQIv8bo^eQthL z_?ldmUCoxqm~EcuMXZpkP6o}koFZmy#Ks2u5!g&J#R{hlypt8sW3jq`YUM|qs^}_y z#?qfyx}VIS;|%Z&m6y7V%H}U4?s?V#UVe*gYh)kuR!6*5ygTA0iM2=~eyK8Imz`_1 z%9p=?VcymF`Hj5h{{w6G2DSaKtQ97#65t%^))K%o literal 0 HcmV?d00001 diff --git a/out/production/lab-java-interfaces-and-abstract-classes/VideoStreamingService/AppVideoStreamingService.class b/out/production/lab-java-interfaces-and-abstract-classes/VideoStreamingService/AppVideoStreamingService.class new file mode 100644 index 0000000000000000000000000000000000000000..23b85caa6273538631de0814644092de6a11075d GIT binary patch literal 1703 zcmaJ>O>+}R5Pc)t+O@p4Wmz^50$H5INPxUlNT?7g#x^#fM6w+uL}cFIv`W~P7t=htTd zR!|8cfB_AI28Ix12;b#xZq>M5wbn{^McHErrlc*sd4_>lyf6$M!x};cMqnH=&uuq7 zQ70>>MTe#`z9Z>a>#nrDoaYK&PwE(BIQFIA3hCvQH8XcJn_aw7>_8!eF`*%1U=mS= z$sR5kw1#q6vnfWb6U1jr5u{yB#tRyz_m8$bS+f>hmv3ie(+gorWqOR^ctKW#)8Ryi za>8xPvaqsFTM8Y=8HUq#Su{N9*ujMe=|nArqj*h;WHKD-5jedZFN|OYuWNY2z?+z5 z81wo2BvgEohF2p&7@*dGPmpI+tX`EB65`9>u z;{_cSLnyx~%q%C7wt@?j7yPE<0>k(+&uQjP5-S>WdaYML{4-I6H zr4Uu&rR_To!(m^0Z%M}*!)z*%NId`H>GNj~X!7Sz-%x)rIl$*Ne8e!<`}!6ejh-8n z$rYy}=ngW{7OSm#Nw|4lsu2>&IAvZda967J9ysW2$|l44OiyoCzc5LPQ|FRC%yjH_ zuOGuO)K(vY;Y1(Ten91iyH#Q^*~1Oh3Ev5AhhMsK_3-K7^x=HA8~Zs~UAC$JWiU^! zMspr7-^=pGo+_c7({jt=s#Ln2=qJLQdSW<*bt-qN1wdINNc|03Su`>lhtBMP{o-%u zs8`#n&r@%73~&<#TIsljj|ri}Y#mfS348hwT4eMQ#-CuSxPv2^vrlle7dkQ~gPvgo~rQ(W-0Sagsou= zWsGBs(62FpAE`$Fj3^#cRi!+AjZ6#>9zhWsG$TcD8=ue^#shqc&q%M&X{D6xAYago Y6EcRt-}qL;jE2j9QAJ}Y5gI`GKMkF++5i9m literal 0 HcmV?d00001 diff --git a/out/production/lab-java-interfaces-and-abstract-classes/VideoStreamingService/Movie.class b/out/production/lab-java-interfaces-and-abstract-classes/VideoStreamingService/Movie.class new file mode 100644 index 0000000000000000000000000000000000000000..a5bd952177bf47139c50dd7bbd5077b8e30e3c6f GIT binary patch literal 1113 zcmaJ=-A)rh6#k|y-Lk9{D}u<6MM2x5)ZZIROtgi#Nr8mcdZ9N%JHo)SLw2W4cnZDr z(g)B)jXw!7Jb;hEJ+ELqyWPZ^Rxf7eoHO4!-<)q|e*QW>0kDb(CSr&iNLUy`l3}_b zTSC>eC-{MMcWT1x$fhWUQHJD-bftd8Fp;b7@eVIK+}$Y>nxG{+-xx*;!v;(XBe4Ei zY+ZGvpkf}^l*hm-CgqJ8FGV;Ul~9~MFv9~42iO8Q5)&1bj3#d zU|V=~zU@#XQ&mmwG`J@NKME%Ft|aE!>R^FGO-c+yTIz0%K7C1=Ry)v4xuluRU{LqA z`${pGHP!Z-Voe6AW>{-E$Y&UPqLlWv#}C(q-c>C>g&afi?A?#EllR$rK=v@p%+uGO zvz4eg`E>Q>R(Lz)oPKzdPNHC92{#Sg3dCJzSom{3>2}nT>v!(v}ggN|z89>d)Kq4c`DePN!SYm6QxqnSPhSuwJQFh%oa@?IiN9$*!g zX1;?J@?T+m3Q^NEkJ2tMj3i9T9>ENG1te&;FpD`_1M3R1R4uUPaW!NMKOp5YT*Fwz zv_g3SDpUA|b2QEuzQ8!fMc^YvV+iTTc@~6#j-@wp|vA6+z@;QPj35^=@K`i57^PR7mVvAM|BtM;Iu(&F-`bzrt6a zj6c8!HC_^8_yPV5-}wv1vlpbM4G%MW&Y5q%Z_YV0`|HoaA%Imp&@qIVhPZ(Qk_^*z z*%VGqxq|OWd#fhgu55@>5M@X%OIxZ(3={e44)5|(i`!czLKC!X7V2rFkk+6Z7>2* z*`& z=h5Lu%V&Lt$7;0 znt@9+LZxJ+WRf4Sg-RzP{*M9}A(7EQAQy=q3uw3;320ad1gKOPi)fbv86aEyju9GX wieI4};2iLYSi>~@BM>5BHzGS^kKt;7x`sS`Q?#~7qkvoF>15r;UEIgiUjURT`Tzg` literal 0 HcmV?d00001 diff --git a/out/production/lab-java-interfaces-and-abstract-classes/VideoStreamingService/Video.class b/out/production/lab-java-interfaces-and-abstract-classes/VideoStreamingService/Video.class new file mode 100644 index 0000000000000000000000000000000000000000..a6ff3b443d20a7ab0e7a0d56a014ba206c542fc2 GIT binary patch literal 644 zcmaJ;?@QZI6g@YlO-<8QGj-E-vwmwkSpNWJApU?ru&`zYKc?-oKB)<0sejczY@i7H z;2*F*YV5qUAXpiJ_wGHp=iKw|{qy(t6M!?cTv%9hV0$Q`EZDe-@8aGpPNu#7=thlm zLHS50I{zYAYj=k0s9@cJ>!Auy@P4Q#DjnpRif?r?9jNS1k5#Wg1*Is6!ZU#%KC7~p zg@;C`?xBGVLFM$@*W)PYUkD@+?6glW=ln*rDde6+=}Tky^J82M%bylv14HhKEYF3nDOH@c6I?xzPh-R1*o zzX(})!_y}L;MUAG_|@TJi%4rh!!~x9Q2=k*MvCYi8(EBZvA1l~<8A(xy7zE?GFXV0 j3$RuQF36>&Aoq>tE9Bab7v#-VvdvYnGf4kfRPX--4O(y~ literal 0 HcmV?d00001 diff --git a/src/BigDecimalOperations/BigDecimalOperations.java b/src/BigDecimalOperations/BigDecimalOperations.java new file mode 100644 index 0000000..d6bbb0e --- /dev/null +++ b/src/BigDecimalOperations/BigDecimalOperations.java @@ -0,0 +1,16 @@ +package BigDecimalOperations; +import java.math.BigDecimal; +import java.math.RoundingMode; + +public class BigDecimalOperations { + //METODO1⤵ + public static double roundToDouble(BigDecimal number){ + BigDecimal roundedNumber = number.setScale(2, RoundingMode.HALF_UP); + return roundedNumber.doubleValue(); + } + //METODO2⤵ + public static BigDecimal reverseSignAndRound(BigDecimal number){ + BigDecimal negatedNumber = number.negate(); + return negatedNumber.setScale(1, RoundingMode.HALF_UP); + } +} diff --git a/src/BigDecimalOperations/BigDecimalOperationsApplication.java b/src/BigDecimalOperations/BigDecimalOperationsApplication.java new file mode 100644 index 0000000..82e2cce --- /dev/null +++ b/src/BigDecimalOperations/BigDecimalOperationsApplication.java @@ -0,0 +1,25 @@ +package BigDecimalOperations; + +import java.math.BigDecimal; + +import static BigDecimalOperations.BigDecimalOperations.reverseSignAndRound; +import static BigDecimalOperations.BigDecimalOperations.roundToDouble; + +public class BigDecimalOperationsApplication { + + public static void main(String[] args) { + BigDecimal number1 = new BigDecimal("23.2323232323"); + BigDecimal number2 = new BigDecimal("32.3232323232"); + BigDecimal number3 = new BigDecimal("-32.323232323"); + + System.out.println("TEST METHOD 1 ↪"); + System.out.println("NUMBER TO TEST ➡ " + number1 + "\nResult Method 1 (ROUNDED TO 2 DECIMALS) ➡ " + roundToDouble(number1)); + System.out.println("METHOD 1 TESTED ________________________⤴\n"); + System.out.println("\nTEST METHOD 2 ↪"); + System.out.println("NUMBER TO TEST ➡ " + number2 + "\nResult Method 2 (INVERTED SIGN TO NEGATIVE) ➡ " + reverseSignAndRound(number2)); + System.out.println("METHOD 2 NEGATED NUMBER TESTED _____________⤴\n"); + System.out.println("NUMBER TO TEST ➡ " + number3 + "\nResult Method 2 (INVERTED SIGN TO POSITIVE) ➡ " + reverseSignAndRound(number3)); + System.out.println("METHOD 2 POSITIVE NUMBER TESTED ____________⤴"); + } + +} diff --git a/src/CarInventorySystem/AppCarInventorySystem.java b/src/CarInventorySystem/AppCarInventorySystem.java new file mode 100644 index 0000000..95d7262 --- /dev/null +++ b/src/CarInventorySystem/AppCarInventorySystem.java @@ -0,0 +1,27 @@ +package CarInventorySystem; + +import java.util.ArrayList; +import java.util.List; + +public class AppCarInventorySystem { + static void main(String[] args) { + List cars = new ArrayList<>(); + + + cars.add(new Sedan("1425MXV", "Hyundai", "i30", 35000)); + cars.add(new UtilityVehicle("2323FFF", "Ford", "Kuga", 3000, false)); + cars.add(new Truck("1456GHH", "Chevrolet", "Silverado", 3200, 10000.0)); + cars.add(new UtilityVehicle("4589NGT", "Volkswagen", "Atlas", 14000, true)); + cars.add(new Truck("2555MGT", "Ford", "F-150", 4000, 10000.0)); + cars.add(new Sedan("3345GTX", "BMW", "M3", 1000)); + + + for (Car car : cars) { + System.out.println(car.getInfo()); + System.out.println("<----------------------------------------------->"); + } + + + + } +} \ No newline at end of file diff --git a/src/CarInventorySystem/Car.java b/src/CarInventorySystem/Car.java new file mode 100644 index 0000000..742f4f4 --- /dev/null +++ b/src/CarInventorySystem/Car.java @@ -0,0 +1,54 @@ +package CarInventorySystem; + +public abstract class Car { + + private String vinNumber; + private String make; + private String model; + private int mileage; + + public Car(String vinNumber, String make, String model, int mileage) { + this.vinNumber = vinNumber; + this.make = make; + this.model = model; + this.mileage = mileage; + } + + public String getVinNumber() { + return vinNumber; + } + + public void setVinNumber(String vinNumber) { + this.vinNumber = vinNumber; + } + + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model = model; + } + + public String getMake() { + return make; + } + + public void setMake(String make) { + this.make = make; + } + + public double getMileage() { + return mileage; + } + + public void setMileage(int mileage) { + this.mileage = mileage; + } + + public String getInfo() { + return "🔢Vin:" + vinNumber + "\n🚘Make:" + make + "\nModel:" + model + "\n➡Mileage:" + mileage + " km"; + + } + +} diff --git a/src/CarInventorySystem/Sedan.java b/src/CarInventorySystem/Sedan.java new file mode 100644 index 0000000..82f4182 --- /dev/null +++ b/src/CarInventorySystem/Sedan.java @@ -0,0 +1,8 @@ +package CarInventorySystem; + +public class Sedan extends Car { + public Sedan(String vinNumber, String make, String model, int mileage) { + super(vinNumber, make, model, mileage); + } + +} diff --git a/src/CarInventorySystem/Truck.java b/src/CarInventorySystem/Truck.java new file mode 100644 index 0000000..015ec2f --- /dev/null +++ b/src/CarInventorySystem/Truck.java @@ -0,0 +1,25 @@ +package CarInventorySystem; + +public class Truck extends Car{ + private double towingCapacity; + + public Truck(String vinNumber, String make, String model, double mileage, double towingCapacity) { + super(vinNumber, make, model, (int) mileage); + this.towingCapacity = towingCapacity; + } + + public double getTowingCapacity() { + + return towingCapacity; + } + + public void setTowingCapacity(double towingCapacity) { + + this.towingCapacity = towingCapacity; + } + @Override + public String getInfo(){ + return ("🔢Vin:" + getVinNumber() + "\nMake:" + getMake() + "\nModel:" + getModel() + "\nMileage:" + getMileage() + " km" + "\nTowing Capacity:" + getTowingCapacity() + " kg"); + } + +} diff --git a/src/CarInventorySystem/UtilityVehicle.java b/src/CarInventorySystem/UtilityVehicle.java new file mode 100644 index 0000000..0591510 --- /dev/null +++ b/src/CarInventorySystem/UtilityVehicle.java @@ -0,0 +1,26 @@ +package CarInventorySystem; + +public class UtilityVehicle extends Car { + + private boolean fourWheelDrive; + + public UtilityVehicle(String vinNumber, String make, String model, int mileage, boolean fourWheelDrive) { + super(vinNumber, make, model, mileage); + this.fourWheelDrive = fourWheelDrive; + } + + public boolean isFourWheelDrive() { + return fourWheelDrive; + } + + public void setFourWheelDrive(boolean fourWheelDrive) { + this.fourWheelDrive = fourWheelDrive; + } + + @Override + public String getInfo(){ + return ("🔢Vin:" + getVinNumber() + "\nMake:" + getMake() + "\nModel:" + getModel() + "\nMileage:" + getMileage() + " km" + "\n4WD" + fourWheelDrive ); + } + + +} diff --git a/src/IntListInterface/IntArrayList.java b/src/IntListInterface/IntArrayList.java new file mode 100644 index 0000000..252df96 --- /dev/null +++ b/src/IntListInterface/IntArrayList.java @@ -0,0 +1,33 @@ +package IntListInterface; + +public class IntArrayList implements IntList { + private int[] array; + private int size; + + public IntArrayList() { + this.array = new int[10]; + this.size = 0; + } + + @Override + public void add(int number) { + if (size == array.length) { + resize(array.length * 1.5); + } + array[size++] = number; + } + + @Override + public int get(int id) { + if (id < 0 || id >= size) { + throw new IndexOutOfBoundsException("Index: " + id + ", Size: " + size); + } + return array[id]; + } + + private void resize(double newSize) { + int[] newArray = new int[(int) newSize]; + System.arraycopy(array, 0, newArray, 0, size); + this.array = newArray; + } +} \ No newline at end of file diff --git a/src/IntListInterface/IntList.java b/src/IntListInterface/IntList.java new file mode 100644 index 0000000..4be9486 --- /dev/null +++ b/src/IntListInterface/IntList.java @@ -0,0 +1,6 @@ +package IntListInterface; + +public interface IntList { + void add(int number); + int get(int id); +} diff --git a/src/IntListInterface/IntListTest.java b/src/IntListInterface/IntListTest.java new file mode 100644 index 0000000..de8e2ee --- /dev/null +++ b/src/IntListInterface/IntListTest.java @@ -0,0 +1,38 @@ +package IntListInterface; + +public class IntListTest { + public static void main(String[] args) { + testIntArrayList(); + testIntVector(); + } + + private static void testIntArrayList() { + System.out.println("Testing IntArrayList:"); + IntList intArrayList = new IntArrayList(); + + // Adding elements + for (int i = 0; i < 50; i++) { + intArrayList.add(i); + } + + // Retrieving elements + for (int i = 0; i < 50; i++) { + System.out.println("Element at index " + i + ": " + intArrayList.get(i)); + } + } + + private static void testIntVector() { + System.out.println("\nTesting IntVector:"); + IntList intVector = new IntVector(); + + // Adding elements + for (int i = 0; i < 100; i++) { + intVector.add(i); + } + + // Retrieving elements + for (int i = 0; i < 100; i++) { + System.out.println("Element at index " + i + ": " + intVector.get(i)); + } + } +} \ No newline at end of file diff --git a/src/IntListInterface/IntVector.java b/src/IntListInterface/IntVector.java new file mode 100644 index 0000000..dd2c57d --- /dev/null +++ b/src/IntListInterface/IntVector.java @@ -0,0 +1,31 @@ +package IntListInterface; + +public class IntVector implements IntList { + private int[] array; + private int size; + + public IntVector() { + this.array = new int[20]; + this.size = 0; + } + + @Override + public void add(int number) { + if (size == array.length) { + resize(array.length * 2); + } + array[size++] = number; + } + @Override + public int get(int id) { + if (id < 0 || id >= size) { + throw new IndexOutOfBoundsException("Index: " + id + ", Size: " + size); + } + return array[id]; + } + private void resize(double newSize) { + int[] newArray = new int[(int)newSize]; + System.arraycopy(array, 0, newArray, 0, size); + this.array = newArray; + } +} diff --git a/src/VideoStreamingService/AppVideoStreamingService.java b/src/VideoStreamingService/AppVideoStreamingService.java new file mode 100644 index 0000000..3468e9a --- /dev/null +++ b/src/VideoStreamingService/AppVideoStreamingService.java @@ -0,0 +1,25 @@ +package VideoStreamingService; + +import java.util.ArrayList; +import java.util.List; + +public class AppVideoStreamingService { + static void main(String[] args) { + System.out.println("~~~~~~VIDEO SUMMARY~~~~~~"); + List