From c6629a1b6245ce8dc0b6609709a84fb2a25e4fc2 Mon Sep 17 00:00:00 2001 From: Chahrazad650 Date: Thu, 6 Nov 2025 20:29:58 +0100 Subject: [PATCH] Ajout de la partie view du projet --- bin/Main.class | Bin 0 -> 1732 bytes bin/model/Car.class | Bin 0 -> 1500 bytes bin/model/Circuit$Cell.class | Bin 0 -> 1167 bytes bin/model/Circuit.class | Bin 0 -> 1070 bytes bin/model/GObserver.class | Bin 0 -> 201 bytes bin/model/Game$Builder.class | Bin 0 -> 2827 bytes bin/model/Game.class | Bin 0 -> 2215 bytes bin/model/Map$1.class | Bin 0 -> 634 bytes bin/model/Map.class | Bin 0 -> 4837 bytes bin/model/State$DriveMode.class | Bin 0 -> 1138 bytes bin/model/State.class | Bin 0 -> 715 bytes bin/view/FenetreJeu.class | Bin 0 -> 2412 bytes bin/view/FenetreTableau.class | Bin 0 -> 3102 bytes bin/view/PanneauCircuit$1.class | Bin 0 -> 756 bytes bin/view/PanneauCircuit.class | Bin 0 -> 2576 bytes bin/view/PanneauClassement.class | Bin 0 -> 2505 bytes model/Car.java | 118 +++++++++++++ model/Circuit.java | 139 +++++++++++++++ model/GObserver.java | 14 ++ model/Game.java | 144 ++++++++++++++++ model/Main.java | 37 ++++ model/Map.java | 284 +++++++++++++++++++++++++++++++ model/State.java | 40 +++++ view/FenetreJeu.java | 61 +++++++ view/FenetreTableau.java | 53 ++++++ view/Main.java | 24 +++ view/PanneauCircuit.java | 80 +++++++++ view/PanneauClassement.java | 47 +++++ 28 files changed, 1041 insertions(+) create mode 100644 bin/Main.class create mode 100644 bin/model/Car.class create mode 100644 bin/model/Circuit$Cell.class create mode 100644 bin/model/Circuit.class create mode 100644 bin/model/GObserver.class create mode 100644 bin/model/Game$Builder.class create mode 100644 bin/model/Game.class create mode 100644 bin/model/Map$1.class create mode 100644 bin/model/Map.class create mode 100644 bin/model/State$DriveMode.class create mode 100644 bin/model/State.class create mode 100644 bin/view/FenetreJeu.class create mode 100644 bin/view/FenetreTableau.class create mode 100644 bin/view/PanneauCircuit$1.class create mode 100644 bin/view/PanneauCircuit.class create mode 100644 bin/view/PanneauClassement.class create mode 100644 model/Car.java create mode 100644 model/Circuit.java create mode 100644 model/GObserver.java create mode 100644 model/Game.java create mode 100644 model/Main.java create mode 100644 model/Map.java create mode 100644 model/State.java create mode 100644 view/FenetreJeu.java create mode 100644 view/FenetreTableau.java create mode 100644 view/Main.java create mode 100644 view/PanneauCircuit.java create mode 100644 view/PanneauClassement.java diff --git a/bin/Main.class b/bin/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..7f0fe759c022d10647c467754eba7faa7011c0b3 GIT binary patch literal 1732 zcma)7?N%E_7=DJ3tSk$JRD-paR+{35V7FT9SCCq;wA2lyB~sJ+HAyD0?PeEeXF=}4 zoAFQZz&T!k#|!Z)Jie1`4+$XpV|Qlf{eIqO-u>h6!`}hi#g>U7qznvONF&3LeZhCR zAH^0Fh1bBY+#CE zV%HOU&WZ?xlH#F=P2_P=SNImm?7mdW#Z41$k|SjEUR$R6Doz?v@5+!NTXdfu`gw$-Tz5Ck@}{`>@+kl2D@dGmQDXU2pP&Rx8|OSU4Y+v+KO45$d`#H^Nvp#EPe5kLcWP zXs%G9OJS%YCHYQ8sO_*BWs#Xk<0}&`DhAdpJiLA}}DrQLb%*1niYv4Nz-{S{j3}z=NhQqJkTSFXNr^Y0Udh1`MnFJEC9x{|kE|&$sQr zo{8sW?)w{_5@iN!H6Tha`#g#SU3epzY6cn%*H58yR-p!{-P7l*(k$(vf_JDnLo^+L z6kSo8y!8HpzAn?sXid)@fc;7vMl%{+F))k~EMYlO{e{d@Bs2yOW12faXcn3N6 z2>Dv+0B=_2OSRu{>FFWGLkHK7P^?X+{+cfxq68ek>EMGS+^)US`dA-+(!poPk!L9; zXiU@G$0+T`VIqeyT%xHxhYM6j9vhg-nwn@yX4CqYqO+bWbx=O`rHcgFq_9Hk5bomv ntyk&0M$al9(xZ2e$>ZbXY?ID@BrQD@4B{}S9O`JIg^T|HgjTr{ literal 0 HcmV?d00001 diff --git a/bin/model/Car.class b/bin/model/Car.class new file mode 100644 index 0000000000000000000000000000000000000000..82fb67df26a31f2fcb9fe2a6b099efb37c887c18 GIT binary patch literal 1500 zcmZuxZBrXn6n<`ASV$HKF+dA_2}p3W)TGu{s-dkd7F-RbQydu74{pL51DoAUvSI2U z=m-4`I{pAZ=!}6GJELD6f0X*1-9RJL*~z_k&pzjz=bY!<{Qb}Ge*k!hrzyk`*O1VW z#E3%X&_1@yuI)9-+qFZd9w>~gHN9qVUmmU!IM@eXbgPJrbFPUqNmS*cO{f}b_q z)^P{#DQKSaT)wkr!?KF}md0Hj@8bi7(UyJWZ28A*#DrlL2fbkTD}q|naSxO*T@TYc z8|)!FW(?yre5f!P5#HRcb;-h^c2kD+zs44K$!wk45?pP1&XZoN=5#)@Yp!U(=GTw5 z?DpVY3VP~yo6>1=6IMfouKSpVg zx7A`{f2(?}doxKSCl2G0Wt|Iao`LJ)ZQSEHzp_!KVY? zeF`cAV$f~&M=VC(MxzCp4sPi&a?f~-2U;I zQxEexrZJ;p*1#MdQXl^bTYkGiwa#s??d*SKSWovvmp!}H%J(?TFmV0Td~XGwK;&OA zkisJxuHgD^xXCcuo2naG$sB1=bQ*j?LrjCAVL(HYJDwO=L5|NYnrShNr89jery4gD zxlD(~Fi>@UXRqBjc7mFH?2#wkr+B8{8W|G1PWY*La$pB`!wH>$D#uLs)VITSK$)a; z=7>(WQ1`lXE%q#gPhaSlb~DeQo6UAmceY*LkkJ*^3g12D+jCmsPO}xNc*79Cr70p; zeBTMg`W((COyJT4ZYRtf1|Cx~Dpp>rt^mA9LROiz$teu7z22a;*Y9jK5sU0NDyM1YRfsJmWu$yS-2jxjFN|#u=fFz8xEDTi`8ATYnFtSl$#D%e}3L|la z#}^p-Kg}fHHpURg4E>BLEFp_EYQBU)s`+oImv}{-2wu}b91GYaYuW6o%i+3=GiWLyG;bT3ZzcEo!x!nx;rYBq?BkkXTm(+|+5OLo+ipapl?{ zqHbKMv6{H>2l%6m=gy3@RoL8n=e_TF&bjBzuirm@0w`fKju0dTvWhSw4CzDtR4?{4|&gJh&(YY!`)_(a`{dSQN$F)RZKx;NE{FP+$@$2yEin*E4!~xI74>tlD<~v zrnwbI5-9~~6<3g9$oy|%PzHA2uyoT)Ru##zDz0LNA$+QvLqaoBlbBO6FY?RHMrl_F ziz=3c5PtDjxu)W}r?lFoW?OhxRNNFwq*AR{ThAC~bK~mFcZgf2cQK^)42#!?$6ao> z^{z?E+}Mz+h>1Gf?f6Aza@G80^cKDCfV*w4Ju|s~Zv6%kf-C_dVmQr#-uD`@PmON5 zdhe*Fp9FO%hC_-?Esq*bg$CrjVu-f}L%YW-hNx5xhO#au$}m;uj$7m6DGps$EsNV_ zQ+FIrpRyPbR;b+}`YS@ni0OJK>OJjIP-n49>l%G+l0*11+IKLma0W#yd_&?4)1OIY zxFzl&(^{hSDPkzo$ag))?SQdC1c@A}bH>sbK#c%(0yJoR&nff{asgm9C_>Q|DNg$| z$}E0pV4v!JN!C2HAYhqxMmJ&YE0lA4#1nh87N}_dffudQA4g>0dPJtXxEENrDVv}! z2k8VKYoaHQX-JD(vGO8IAV#O2v*uBEKef5@d#mrk{;mx iB*2YHfVUR`5*~OJKEwv?GF6boBRa*sQxuPP=KlZ@&#ayR literal 0 HcmV?d00001 diff --git a/bin/model/GObserver.class b/bin/model/GObserver.class new file mode 100644 index 0000000000000000000000000000000000000000..c276b20456388a8aff527c70667cd64c08d1799c GIT binary patch literal 201 zcmYL@u?oUK5JYFyBpN|&t!%Y1A7GUxA_xHm3%g5P<-+9>l1so}v+x7_DDh&U&F(Vn z%)Hn8@dOZJ?4d`P=Ea3ou#JQ@*jX5v_Ivtjo1#t+OCt6iYW%zRoz+6$iA&~7kH-*iR+3GJ8 zIAOcI*=?;x-_;a#S0!g!)shmw6tz1)Y__Q%{YtYLwXW5}b~~ao+1z(jG>3W_FleRb zq^FeXyBMjL2rW=U#cP?~7D!VN4hOpsfwcoW5Ie{OPmrtb;=~RL4{2B60X+@+&Zd&uCS?CMlMRZ3iRD&#&~T4b}Am3KaGvNj}GHpTU%hdDvi>3`R)x3tT+P zpwMS9Mh4@gO1-8Htlwa(*w%*hp5lY5Aq!72Ts4eG7+tQWHJBPK4YmeHgJh{>u}tJH z?|X~`j6P$AG0Ql}C>e8%dBzhl5~uga(2SEJWlCd?G4JU2grV8X(293Wt!!zqH8|{n zrIN)mk-NO_F%B^L%%m@eyx*5YmM09YUWR)2c&p42|0_fLf6vf)`wWvRb1t)tgGnDA zzA3z)R9U`*GBbs~GPC@j8d1K3I=?B!Lxt9t{dli)a#;=+n%`f2aO9r;(&Xh|y`LQE z_I9H_^YPy3f15|v=WbjKrXFFecZgj?hNj+G8k9vmq<=rl2*jV5N>+u#W^)P nQ}K}2v-T2=>3PhNl*YSH%cWRh9+zVb@HL@Ft{wV!wE*{Tamqc~ literal 0 HcmV?d00001 diff --git a/bin/model/Game.class b/bin/model/Game.class new file mode 100644 index 0000000000000000000000000000000000000000..fa5242a9d16b66f90f85a61da56bf4c18a3146bf GIT binary patch literal 2215 zcmZuyTT@e46#fo5$syqYDuhA-jn--ix0bfp5=9XKqv2wMC|Y$6$u=BJPU6Xlg1y?> z=}Z5BJo>_mGp(J1TBo*CpW0v0f6(@+Po3#7t@PU`;pUVX_TFdjb@|p>-&*hQv+V8@(s!|2W!R=Rt9W=

1-`?kWjg%|JmI#f04m|v5YSNtU4cKF zONmVPsF7Dtl@`u~;mjt?Tf!BN`B8&f4Lfw~#4ZJalJJO;mG4Q}*y{=!ky)_gK z#}w3->oh)75cUmWOUTD{3`)rAO~Z7ma1=v2hNW|_k9{7H)w)rTj>&72wvlAt_!DN@GMu8# zbD4|V>3_J);gR+7Mf;-)S~j@NUX8v$bAlUWAJbjjw8U63J0t8#V>^9!W3RZgqnc#goCKvN zVv|#_Cfv5Q>p4XdxuTsE!={Aim&2q>=94hSNSaY0!51`q%DyP`m?Ha+7tKsckb!#4 zvV=XDF$x7i^IG`}+p5>`R&K`H?^m2Dj6DY{I=PWdyy|B3Ec=HuCHST93 z5219dKEd=6eV~LEUsv?RFSdJ`FXBhDr^#q5!LiFg$X+41R`RlF|nxig^3eBcA@&mV0PyZ|&(*o75E? zT!dG>f5$^We|YXwvH}uOgR7N5J)d{oM3KYm~pl3|vMtuDBk8@Kl{+$x-cuT=u4DrCW_z_1(BhzC)m2d=zV_<3Rug+&n2=u9)&zjU9 zIv(SMg8tS;)P94JU85@)S0CZ*(%Pd3w7m!2=%M`{&R4mY(o!l^ia@VY!o&eKb0@N# z))ottW7)1F4x2@Cn6RQ7%pPd}$olmDiv|rxHB?le&~RfFzEw1=((pXZtIS%O{|gMT zM7tzkByC#>eR>g%+}^9ll}9j^*8YsQufSYd`|SaRHU0+IQ@Mn2x69Q9t{*a`AMx!r zUq3;Rdka2u5mhqf2@Pq<^ILeo?68%)ES;ArtNxk?#btuT1AM{t1DY&h+bSA-QS?h% Z|A;CT_?Ui6q1~ouklG4S)Zh;M{{aZf)t3MO literal 0 HcmV?d00001 diff --git a/bin/model/Map$1.class b/bin/model/Map$1.class new file mode 100644 index 0000000000000000000000000000000000000000..a89ea3b8f83362a3b0b2b140e53f498bd84e7d5c GIT binary patch literal 634 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 literal 0 HcmV?d00001 diff --git a/bin/model/State$DriveMode.class b/bin/model/State$DriveMode.class new file mode 100644 index 0000000000000000000000000000000000000000..12aa3983d78fa0b67ade4ac6a727ab1f4d5729e4 GIT binary patch literal 1138 zcmZ`%ZBNrs6n@UyuFw_OCIg1x3rt;yGEoq9gs>pSC4(6!B!o}hxME4yC0)m7f09BF z;#>Iak20QHCoI64Z0Fv4p7WgNy!`(2?H7O|3OXW$RHL~o+%}r*w0teLAi;em`e6|C%vQ0yxmG2N?eu^fFfpLRFfoWBf>w8%o*)co zt@6HoVCP-i+sjvK`=TBc3?z`$al^zgQiQ<^z?#=?aJmEAZHvkW!a}wydeyaCtwPsB zHSis8uh5-A5`_GtCdQEFI+q;J36=>X-Bg{(lC>qvylG+rlU#1y_G_Chu}h$mblf&^ z2Y1=wc!BU)6(O=y>VsymGb1zHBc!h*E|r*Dq8^yY!jdfvi)smN!XD~nW zjqs5FqoGe_{4gFN(!oc^(SasIfPQZs3G2>OLOgOh>L2~MHn aU-GAz4@E5CS!fsWg00+W!XjR-r2hh2vE4TS literal 0 HcmV?d00001 diff --git a/bin/model/State.class b/bin/model/State.class new file mode 100644 index 0000000000000000000000000000000000000000..513d5bcefc9a5bb01ea5798fc63568752e40bbd6 GIT binary patch literal 715 zcmZ`$TWcCo5dMz4x@tD&USsa}?pmlnpd}<20)iUI#g{y-<`6cl$FRHltNPG}ltLf+ z1Nx&%zmXszn1?enXXcxkZ)X1f`~3&NDf}WbupHPfvdAgSKLn$o76sP4vH>j;3};22X{KEU8O;)56Ky&&%1B>GN4H5Ban zn892#G`cX(-$byK*q>b(Qx2#v9vpz7%u>Y8b12bL&-Bu#i z*1UI$`5lGg)nFL+^m!=Vi{l-Ami4kxTPJBt3%NwWZ5X5DdK4sy=C?4}BX+r^4DZC5 zWlyxSw0S7XHU2#M6}4Oa1yy~5^Aoc_#`twgIW72XED^PV&6h0El9jDKWA^(5E=7Sd zXRQ?0+f_)MI literal 0 HcmV?d00001 diff --git a/bin/view/FenetreJeu.class b/bin/view/FenetreJeu.class new file mode 100644 index 0000000000000000000000000000000000000000..ad883e046d1ca39d9a06f309bbae2eda15280e1c GIT binary patch literal 2412 zcma)8U3U{z6y3K?J0%@x8z@kqB~l7WT8Mz4l8Uy0LTd_0YoUN2x5;fgG?|Grla?ZW zA%3x3x_r@BmoL8RS~du{@ZIHK@F%c*^-0`!lG0Qv%ZKDn&b{Z{efHVsOn&?O?tK6Q zxD`en>J5ZUG@wx+az)O|t4VLcvS*SbL#`|+fyREzw)|rP^|APbfhK{C`dG5$TlwUG z>&nH9<@sS4s9%R>mRAl0cI$r}9dct_rkfR-)(tsV1}u z#2$S6%Y$FP`19v4qjZSoR5a_9Tu(*!MJGxsT68TtYZYZ)g?ZIR6PwV^sGjo2Ek94N z?XgPOykrJrK9A3&H0mt^+iR0MZ`nC#A??_nFKyq`(K<|Q!*+qKjCNd2%TnG?=N(U- zDJoa`mSYQqV#7LEC+`Ws%LP9<=(suMX5^w%A_+TCuVY0`JcV5X>lmxD#rvz!v{S`4 zDs4HV+yLNi(i+fpR@ychN?UHWWHDkl_UP*DC7rQM!O5w7@+9j*C(U-;L;}468;Yyk z2r#ooG;+L;1x+j4SFXmHH1RYJu(UFl6NuL!Ogn|5WAk9DhR`!pS5(#y@E#J_yy}L$ z^gLCdLl_6KM`Jr;;#oW=(6)^2(Gilo8s4KFB0Nf-Pe`q(e!O7dn28thl0bMRcL8HY z`Dy8TOgt99RHcQ6l!3uzBCEO^uP81|xgXa=o)Fl%Or-Xx09g?!vunmloH8)1$r<4l ztA+Y6ku7s_QS+HGF^bc~$GVSM*C@z_*f2Gt_s*Jl1?T9kHQ{6fNu5)9uJdZ#5!kXO z`xW1D6R%=|B+z%l@+>xyR^vsz+l>n*CbdAC3(9Aw4UDj5bQLZ{*yWc^yoT3Vb(zho zqOY@$*RIh&}@Luvge&S#gS8(%1K@A4Vb;8yZxO!W~aeT3;YLEZ_&B~Qe_N~ge7H?YS^JA8; zk#m`@Qs^n#V|KnTq6 zxel}Zur-2{917UW9Saam`o&A@H;LO2iF+_6Z)4pO!ih+08IeR|8Cz-HL2FkTJNei> z*?Sv3ONb>BKOq+BD`P*c2etK?B^=h)!;$A{?JXlU+IRn0{gF_6sPj8?_qB%(9&O-$ z_#Or(I~sUn`VNNbaQit^D4?L^m?6 zt!PIFUzgj^gH9Yk7gD6+BzAGc^)T5zxX$$k;`p4jd_`iuMjz&a2z3u}84U)S4fGqx z3jzGa!-6`mvVt_((yZ>(IWm#+IxDUhHTt`_1l++Jb02F4WX;n7wHA0@6P Xt?$q_kE?haH)#pe@)174XXy9`C#!Me literal 0 HcmV?d00001 diff --git a/bin/view/FenetreTableau.class b/bin/view/FenetreTableau.class new file mode 100644 index 0000000000000000000000000000000000000000..ea6ed83d59cb1844f0d10462097f06a1ff797e61 GIT binary patch literal 3102 zcmcImS$7mg6#mKtdNMSS3?Kv)MhrL^z(Ei_GA@uvAUKhj#9+j&CQ}Jbdb(pzPeR=H zU2)&{eP3aM@#u@^_~7wZ_y>IV!Q)rmGec)NzWLDI)m8W2y7#;HepSE!GxH08y_k;U zEHoHsG_eSa1ro>Pggl-pO*@E`DKr~OL9fGpzKVi^s+H56KJgpB?~HJ@1@)M~XeEgPFiO9^_Kwv4o?~ub|qn=xK3XDGzL9j^x%(l5{%*nj68R>q-+>VUK`m=WP~FzU*;Rft7(my*h)ih+767COUOc zF$U77p-Dhsm$uYpV!yT&qoo12?3J{5w~2$eCKT`YrO%WuXG%jvf(csf!L21S9{ik>S3`{xgP@tt~W7=!%X$u^40wz?Xo&FBCt7%!lC>zHSA{> z05-uk9nwj;agIu@A?9PL!@tSI%{qL8;qPOl25zl(O&!IKvhTZ23{qgjpC?ZLb^1iI zSC&gEnMwZnaz+34sc}y^1y99s3x;*}656&hF@jNIlV{htPN2lPn4P20dNzRuSSF5P zj8MyA-=e(oMqIC`SjIb2xhRVqROK23y8hJ!8!xjrP|8^)wjp~>yHYgaz!hkbg~IG* zfsK*QSkOS&;f{vkWnbBGG%077;4wUI;0Y5?)_Fdp)S3uU@X8LWAQhqP z`H2~15S^@YI+G*qU0W{Zl^1Y2gYo2uC#~V57U|BkWielnZH}63+b*zuev-qQotxu* zI^QHR(j9woc&tZ`*Ua~`gNId@rH_Rbv(KChb(68zI$YN;`JNo_QT|c4P>SId8mf~> za(7b1@EZ9qV1w}Y4gUW6INL-2Hsh@TgF1Uh%cths^2K;Zr~6$K&*C}$y&uO1_|U*d zx<@}2XgkyMmNVgwsp`oUa%mS^!1bmCUX6BtRWNk?fOHDBDz)WYcdR^~o!{P(nOTYh zQ{!p@@gouW1!$&fqEp&-zvZheL;5t1&+xf{FHC%iuh>%aLdpdRroVEe7SNJn^zV=V zKfM2peb!=#XcU@R%K>gt=A8=(E4teu_jKB_R8l1a-?Ggk=far-faO#_3=I4ruxTE2 z3nkgWDS`F>Ey~MSSP{Hy#CRq^v$4L3ag@-9X7J^a7ktV6!IwPEZvzj-MR zHJl0&2&ayOQ_=XjaK_UFeFQGzJ#`0t*vYJ2+#J_DQr&SkzdExmMF0NZVCv70cvL`} zI4cNtS&+K(U|=JfaXy~s3e(%n*9(Eri+G9O_1x(_T6;NozZ$$>$0w9}6L0hRnlk!k S@eOY~-|cC|_c+O9wEhbNU{k&T literal 0 HcmV?d00001 diff --git a/bin/view/PanneauCircuit$1.class b/bin/view/PanneauCircuit$1.class new file mode 100644 index 0000000000000000000000000000000000000000..beef292642307cc66441ba693fc2f491dda0431d GIT binary patch literal 756 zcmZuv?M@Rx6g{)ucH6p0Erk{oMOdXprDCFgG{mORu#vWgZ8U~o)9r)~F1uzw%Deai z{#FxXjNt)%DC3<~(lj!e%$;-Z%{^!ConOCyTmWccrw9!h1GW%ThZGtCn*vV|U!; zAFQ;Bbs7B2qaE7?l5^d}JW34uQNOjvP`Qdx$u65%K!w2w!jbej3C+|Swt*#vl~X?9 zO^^F0&0gRn?zkg`H`))wAXE%B6U&Mr>kL{)1Le7C;+FE{I(E-?4wUP*i92c1JEg^l=fvE7PjCN+i%yV) zuINY=T$t_Fwj!b;`@ZW1k@QcxA|3}L0}m+mitdt*o`~XuARQVnrmr|rnW}EfR$=$Zt6y!b!?Ee2z^9`Zb0Wd*u~G{R~TQ^p8JLydjAvjS1GI# z%ueA7!Q2$C5;Riy89EB6po&G*h~qxlO+3Ln>#gOUS=9DAJuh ksMaP$HPq1{t7D7KhpA@^kI0rOrePb8UoO*|XqEDR0O`Y?yZ`_I literal 0 HcmV?d00001 diff --git a/bin/view/PanneauCircuit.class b/bin/view/PanneauCircuit.class new file mode 100644 index 0000000000000000000000000000000000000000..f0f7b4b0557147c5989172020b82519560e42fd5 GIT binary patch literal 2576 zcmZuzTUQfT6#fR13<*b!XjIfv(TGVvqo`=nq9H_xgg^mNv=s*!VKgM^BoXcXqP6$? z#oC+N3vHj;ERAcmYq{Fj_K)7O-Gy9xtn zkQfoLs8vuS9R;wF?H`u=R}0k1BdMmI z){JCUo^-9iIy^w{mL!~-PN$N3k^!$=WTeZ~(o@EGX0Lx(#e;M(AI#iJOQ#bJ*q~yg zfESw-teW34peHAEljwERWrj!TiHwYf;zQ9;EE*b&#=8_eun=$gZf}o%o;WpNvw#nN zW@9)MI~-Y1AMJ}%SX57F%uwIhX?;9PcU5>hzcCC6edh}IASIOp5f*k0E(lzd-;R+; zEY^2KiY^JfY$+Y-jt)hnE@6|tVx+^J)1T4(4kb$WUUQm+4G2twW{K>f@SmB zn(Ip{uCVJarX)*ukox2LK||VHUf!s;N(=N9*E88(UHT@eMU=hV3@5ZqM$f3Ys$lKB zqkFptQDfIq@g+knONBfc>sQ4$i`!#4uLyCGS?qaLY|j8wEbkT0?3~;2F30!ywTp7O zzASJHN}%Z`)Ic6f3RwQ5rSv|>TG%+cIWB{fUv4a?@(1%K0woi!qIvm5pt+vWmyT|T!UB}VN zR)@#oUU41WTRaYry?~uG#P<+01b=CKtJqP@ud7P>Dul-awtF4#HF z7G3qU*)8jJ_S@HSqR#Gdw6v+xa$jrJ7Ee_HhufTW&Knq^^{SJtE;%19&a0aP9!CLV z($mj4HR5qy@>E~)*xas((s&C~1)Q;*UX|cfKmvP;_b3R6osh_KUxD@fYT)Qa0GqHA zjcCVabo0_W20vR+fK|SU_334$1z9-Tn8WS3!n@=ecHlc|++;?7#cur0%i<5N|A{ty zNH0xr+{H#XR8*<>NJYJhU5Wzy4X1JkJ$GRL2h}P*=EoSr<8@IY$i-52JM&026_DHd zJ+1NC!1Q{kdpkBoNZZKjAaYw@{zK&d>i;~wp=rS zSF8YDw*q);A%Hb-a95OgAHoLoFpwAn=_Q&`%ef2ob#uNe@d@`<;8T3YUmLxr@i}K3 dIRAp)uGyUIo!9ZzfjZ{&Ys`}BX|BUv^&c*nG%^4H literal 0 HcmV?d00001 diff --git a/bin/view/PanneauClassement.class b/bin/view/PanneauClassement.class new file mode 100644 index 0000000000000000000000000000000000000000..7920109622194141eb6ab0e5d85cc4cdc3dbc5ad GIT binary patch literal 2505 zcmcIlZF3V<6n<{I>89Iln}((($V-3%XU`uLC(Uf8ZmD}W&Zkz1J-AzmJ z4HbFw1s%UQeq#L68D{+82rUH%{p|Qx`U7+v^z3fhY(W^mm`pZz@4e?a&w0){_x^VO z&OHFV_*y{?YGp_&0;ppMPw^RkHfhaj`kCawF|LaOL)`&Q*X)A~weil;dIV7~Ls8KH zm7#4$6SGO$s0&_B7r14KqR?&HJ0;2t>R{2xi$b!W7ez`&Q^iA)&)Uhu8tt?+Ls!s< zkVBw_ArQ}GI!6_9vQ9-SA`Br**vCvUAxu-`v)Vbq&>kOjc&x=XUn2h?x!(xjHN2uH?dhQ?JFeTHra5hHTFrp5~jHes7X zcYBpdfsp7M2B<**-lx?k$>@`h3H>g<@{!@5b#xpARVLzEv(?JZ* z2s_P9i-d`Ho~&ewCQ=HX!}BtFRHSf#GVlN{8PsvhL1)+zKk4PdRbY60O5}*YH{~*M zwh>?w2OY^?WQbOxbyw3yp+FW?1Qc}GDM=NFkS3zMR4UB%S{X;6j<_FjqO7|X$q|EA z`zmj#2E2?u8T~4bAj8mFCG8}fo7^@`D#)DsLV0qLd;DY`0qpl(g>wD9qGAw33_(-O z2-6aIhV^T>uGv3~V=`V<@fxxud6l21q+}T;#rl9eE6hor1`Ol4icy?kkSwo%21ydv)d?cuAKO3yGf z$Nfh|=P1RPrlW%v1~pwAEf>dyIl{*aG}BNNwrz^u0i#SAZOqy{H$B8l?y3xO>lLie zDb-V!Hs?g2<^Z%kbYAUovO$K248yi;Ithk^J!#~v5Y9S!`UtO-c&0gki4fj(n#b2V zotYrsCrMar)X?m*DPkxr@EI((?$JU)`~v5HS{fnl3l2rgMopE0IIa*!9t z^PCv)37(^>o%2GjzWweeR59`hAK`kwAgqo-!0)mYz(DBu47GE`K1^cm;R+iFO3 z%w*_7G`)k{lJNx{ln=%9ZyA$ujbZcSw^Dn0>BUyMCTr->Wb~xlm`1fU4xmU+o!(xc zv9lgcEP^GvZb44mMdMft{;XX@^8&&@y2b`Q!;t9NOwSPN(L#5q)8VC6s00ByP>Kh$ zfVQe_6S)N<oCs^+sMAM^fT9XeToJndx6pSlVmOR#=*M;(M+e5~W`{ literal 0 HcmV?d00001 diff --git a/model/Car.java b/model/Car.java new file mode 100644 index 0000000..77b028b --- /dev/null +++ b/model/Car.java @@ -0,0 +1,118 @@ +package model; +import java.util.Random; + +/** + * Car représente une voiture qui avance sur un circuit en boucles. + * Chaque appel à {@link #makeMove()} avance la voiture d'une position. + * Quand la position atteint la fin de la boucle, un nouveau tour est compté. + */ +public class Car implements GObserver +{ + /** Ajout de la classe Random (Evite de le recreer a chaque fois) */ + private Random rand = new Random(); + + /** Position actuelle dans la boucle (entre 0 et loop inclus) */ + private int pos = 0; + + /** Nombre de tours complétés */ + private int round = 0; + + /** Nombre total de cases dans une boucle (doit être > 0) */ + private final int loop; + private final State state; + /** Nombre de fuel restant */ + private int fuel = 60; + + /** + * Construit une nouvelle voiture. + * + * @param loop nombre de positions par boucle (doit être > 0) + * @throws IllegalArgumentException si {@code loop <= 0} + */ + public Car(int loop, State state) + { + this.state = state; + + if (loop <= 0) + throw new IllegalArgumentException("loop must be > 0!"); + this.loop = loop; + } + + /** + * Fait avancer la voiture d'une position. + *

Si la position atteint la fin de la boucle, un nouveau tour est compté.

+ * + * @return cette même instance (pour chaînage fluide) + */ + public Car makeMove(int move) + { + pos += move; + if (pos == loop) + { + round++; + pos = 0; + } + return this; + } + + /** + * @return la position actuelle dans la boucle + */ + public int getPosition() + { + return pos; + } + + /** + * @return le score, calculé comme (nombre de tours + progression du tour) × 100 + */ + public int getScore() + { + return (int) ((round + (float) pos / loop) * 100); + } + + /** + * @return le nombre de tours complétés + */ + public int getRound() + { + return round; + } + + /** + * @return la taille de la boucle (nombre de positions) + */ + public int getLoop() + { + return loop; + } + + public int getFuel() + { + return fuel; + } + + public Car consumeFuel() + { + fuel -= state.getConsumption(); + return this; + } + + @Override + public boolean apply() + { + if (this.fuel > 0) + { + int[] interval = state.getInterval(); + int random = rand.nextInt(interval[0], interval[1]); + makeMove(random).consumeFuel(); + } + + return true; + } + /** Retourne l'état de la voiture (State) */ + public State getState() { + return state; + } +} + diff --git a/model/Circuit.java b/model/Circuit.java new file mode 100644 index 0000000..fbea526 --- /dev/null +++ b/model/Circuit.java @@ -0,0 +1,139 @@ +package model; +/** + * Représente une cellule du circuit. + *

+ * Chaque cellule possède un type ({@link Cell}) et éventuellement une valeur + * numérique (par exemple pour indiquer une intensité, une vitesse, ou un identifiant de route). + *

+ */ +public class Circuit +{ + /** + * Cell est un enum + * représentant les différents types de + * cases qui composent le circuit de + * course. + */ + public static enum Cell + { + /** + * Case hors piste, non + * praticable par les + * voitures. */ + EMPTY, + + /** + * Case de route normale + * sur laquelle les voitures + * peuvent circuler. + */ + ROAD, + + /** + * Case correspondant à la + * ligne de départ du circuit. + */ + START, + + /** + * Case correspondant à la + * ligne d'arrivée du circuit. + */ + FINISH, + + /** + * Case de route jaune, plus + * d'information sur le + * livrable 2 + */ + YROAD; + } + + /** Type de la cellule (vide, route, départ, arrivée, etc.) */ + private final Cell type; + + /** Valeur associée à la cellule (optionnelle, dépend du type) */ + private int value; + + /** + * Construit une cellule avec un type défini et une valeur par défaut + * égale à l’indice ordinal du type. + * + * @param type le type de la cellule + */ + public Circuit(Cell type) + { + this.type = type; + this.value = type.ordinal(); + } + + /** + * Construit une cellule avec un type et une valeur spécifique. + * + * @param type le type de la cellule + * @param value la valeur associée à la cellule + */ + public Circuit(Cell type, int value) + { + this.type = type; + this.value = value; + } + + /** + * Modifie la valeur associée à la cellule. + * + * @param value la nouvelle valeur + * @return cette même instance (pour chaînage fluide) + */ + public Circuit setValue(int value) + { + this.value = value; + return this; + } + + /** + * @return le type de la cellule + */ + public Cell getType() + { + return type; + } + + /** + * @return la valeur associée à la cellule + */ + public int getValue() + { + return value; + } + + /** + * Vérifie si la cellule est une route (ROAD ou YROAD). + * + * @return vrai si la cellule représente une route + */ + public boolean isRoad() + { + return type == Cell.ROAD || type == Cell.YROAD; + } + + /** + * Vérifie si la cellule est un point de départ. + * + * @return vrai si la cellule représente le départ + */ + public boolean isStart() + { + return type == Cell.START; + } + + /** + * Vérifie si la cellule est un point d’arrivée. + * + * @return vrai si la cellule représente la fin du circuit + */ + public boolean isFinish() + { + return type == Cell.FINISH; + } +} \ No newline at end of file diff --git a/model/GObserver.java b/model/GObserver.java new file mode 100644 index 0000000..5051445 --- /dev/null +++ b/model/GObserver.java @@ -0,0 +1,14 @@ +package model; +@FunctionalInterface +/** + * L'interface utilisée pour Game. + */ +public interface GObserver +{ + /** + * + * @return true si la fonction s'est bien passé sinon false (le programme va se + * stopper) + */ + public boolean apply(); +} \ No newline at end of file diff --git a/model/Game.java b/model/Game.java new file mode 100644 index 0000000..632f9d2 --- /dev/null +++ b/model/Game.java @@ -0,0 +1,144 @@ +package model; +import java.util.ArrayList; + +public class Game +{ + private boolean paused; + private Car[] cars; + private Map map; + + private ArrayList obs; + + public static class Builder + { + private int pnumber = 3; + private Map map = null; + private State state = new State(); + + public Builder setPlayers(int pnumber) + { + this.pnumber = pnumber; + return this; + } + + public Builder setMap(Map map) + { + this.map = map; + return this; + } + + public Builder setState(State s) + { + this.state = s; + return this; + } + + public Builder defaultMap() + { + Integer[][] map = new Integer[][] + { + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, -1, -1, 5, 0 }, + { 0, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 0, 0, -1, 0, 0, -1, 0 }, + { 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0 }, + { 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0 }, + { 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, -1, -1, 2, 0, 0, -1, 0 }, + { 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0 }, + { 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0 }, + { 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -3, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + }; + + this.map = Map.fromInts(map); + return this; + } + + public Game build() + { + if (map == null) defaultMap(); + return new Game(pnumber, map, state); + } + } + + public Game(int pnumber, Map map, State state) + { + int loop = map.getPathSize(); + this.map = map; + + cars = new Car[pnumber]; + obs = new ArrayList<>(); + + for (int i = 0; i < pnumber; i++) + { + Car car = new Car(loop, state); + cars[i] = car; + + // Observer pour avancer + obs.add(car); + } + } + + private boolean isFinish() + { + for (Car car : cars) + { + if (car.getFuel() == 0) + return true; + } + return false; + } + + public synchronized boolean togglePause() + { + if (paused) notifyAll(); + paused = !paused; + return paused; + } + + private void step() throws InterruptedException + { + for (GObserver o : obs) + { + synchronized (this) + { + // pause du jeu, while si on notifyall sans faire exprès un autre bout de code + while (paused) + { + wait(); + } + } + boolean isSuccess = o.apply(); + if (!isSuccess) + { + System.err.println("Une erreur s'est produite pendant le jeu."); + System.exit(1); + } + } + } + + public void run() + { + while (!isFinish()) + { + try + { + step(); + Thread.sleep(1000); + } + catch (InterruptedException e) + { e.printStackTrace(); } + } + } + + /** Retourne la carte du jeu */ + public Map getMap() { + return map; + } + + /** Retourne toutes les voitures du jeu */ + public Car[] getCars() { + return cars; + } +} + + diff --git a/model/Main.java b/model/Main.java new file mode 100644 index 0000000..32dbf58 --- /dev/null +++ b/model/Main.java @@ -0,0 +1,37 @@ +import model.*; +import view.*; + + +public class Main { + public static void main(String[] args) throws InterruptedException { + // Map m = Map.fromChars(new Character[][] { + // {'3', '#', '2'}, + // {'#', ' ', 'S'}, + // {'9', '#', 'F'}, + // }); + + Game game = new Game.Builder() + .defaultMap() + .setPlayers(3) + .build(); + + Thread t = new Thread(() -> { + int i = 0; + while (i++ < 10) + { + try + { + Thread.sleep(5000); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + System.out.println(game.togglePause() ? "stop" : "fini" ); + } + }); + + t.start(); + game.run(); + } +} \ No newline at end of file diff --git a/model/Map.java b/model/Map.java new file mode 100644 index 0000000..f7adec7 --- /dev/null +++ b/model/Map.java @@ -0,0 +1,284 @@ +package model; +import java.awt.Point; +import java.util.ArrayList; +import java.util.function.Function; + +/** + *

Map représente le circuit de course.

+ *

Cette classe contient:

+ *
    + *
  • Un tableau 2D de Circuit.Cell
  • + *
  • Une liste de Points qui représente le chemin pour la voiture entre START et FINISH
  • + *
+ */ +public class Map +{ + /** + * Tableau 2D représentant le circuit. + * Chaque élément est une instance de {@link Circuit}. + */ + private Circuit[][] map; + /** + * Liste des coordonnées représentant le chemin du START au FINISH. + */ + private ArrayList pathMap; + + /** + * Crée une nouvelle instance de Map à partir d'un tableau générique + * et d'une fonction de transformation. + * + * @param Type des éléments du tableau source + * @param fn Fonction qui transforme un élément T en Circuit + * @param array Tableau 2D d'éléments T + * @return Une nouvelle instance de Map + */ + public static Map create(Function fn, T[][] map) + { + int lenX = map[0].length; + int lenY = map.length; + + Circuit[][] newmap = new Circuit[lenY][lenX]; + + for (int y = 0; y < lenY; y++) + { + for (int x = 0; x < lenX; x++) + { + newmap[y][x] = fn.apply(map[y][x]); + } + } + + return new Map(newmap); + } + + /** + * Crée une map à partir d'un tableau d'entiers. + *
    + *
  • 0 -> EMPTY
  • + *
  • -1 -> ROAD
  • + *
  • -2 -> START
  • + *
  • -3 -> FINISH
  • + *
  • autres -> YROAD avec la valeur associée
  • + *
+ * + * @param array Tableau 2D d'entiers + * @return Une nouvelle instance de Map + */ + public static Map fromInts(Integer[][] map) + { + return create((i) -> switch (i) { + case 0 -> new Circuit(Circuit.Cell.EMPTY); + case -1 -> new Circuit(Circuit.Cell.ROAD); + case -2 -> new Circuit(Circuit.Cell.START); + case -3 -> new Circuit(Circuit.Cell.FINISH); + default -> new Circuit(Circuit.Cell.YROAD, i); + }, map); + } + + /** + * Crée une map à partir d'un tableau de caractères. + *
    + *
  • '#' -> ROAD
  • + *
  • 'S' -> START
  • + *
  • 'F' -> FINISH
  • + *
  • '0'-'9' -> YROAD avec valeur correspondante
  • + *
  • autres -> EMPTY
  • + *
+ * + * @param array Tableau 2D de caractères + * @return Une nouvelle instance de Map + */ + public static Map fromChars(Character[][] map) + { + return create((i) -> switch (i) { + case '#' -> new Circuit(Circuit.Cell.ROAD); + case 'S' -> new Circuit(Circuit.Cell.START); + case 'F' -> new Circuit(Circuit.Cell.FINISH); + case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' + -> new Circuit(Circuit.Cell.YROAD, i - '0'); + default -> new Circuit(Circuit.Cell.EMPTY); + }, map); + } + + /** + * Constructeur privé utilisé par les méthodes statiques de création. + * Initialise la map et construit le chemin. + * Si la map est invalide ou impossible à résoudre, termine le programme. + * + * @param map Tableau 2D de Circuit + */ + private Map(Circuit[][] map) + { + this.map = map; + boolean isPossible = this.buildPath(); + + if (!isPossible) + { + System.err.println("La map contient des doublons ou est impossible à finir!"); + System.exit(1); + } + } + + /** + * Construit le chemin entre START et FINISH. + * + * @return true si un chemin valide existe, false sinon + */ + private boolean buildPath() + { + Point[] p = bindPath(); + + if (p == null) + return false; + + Point start = p[0]; + Point end = p[1]; + + this.pathMap = new ArrayList<>(); + return followPath(start, end); + } + + /** + * Cherche les points START et FINISH sur la map. + * + * @return Un tableau de 2 éléments : {START, FINISH} ou null si la map est invalide + */ + private Point[] bindPath() + { + Point start = null; + Point end = null; + + for (int i = 0; i < map.length; i++) + { + for (int j = 0; j < map[0].length; j++) + { + switch (map[i][j].getType()) + { + case Circuit.Cell.START: + if (start == null) start = new Point(j, i); + else return null; + break; + case Circuit.Cell.FINISH: + if (end == null) end = new Point(j, i); + else return null; + break; + default: + break; + } + } + } + if (start == null || end == null) return null; + return new Point[] {start, end}; + } + + /** + * Suivi du chemin depuis START jusqu'à FINISH. + * Parcours les cases ROAD et YROAD jusqu'à atteindre FINISH. + * + * @param start Point de départ + * @param end Point d'arrivée + * @return true si un chemin complet a été trouvé, false sinon + */ + private boolean followPath(Point start, Point end) + { + // remettre à 0 la liste + pathMap.clear(); + + // positions + Point current = start; + Point previous = null; + + int[][] coord = { + {1, 0}, // haut + {-1, 0}, // bas + {0, -1}, // gauche + {0, 1} // droite + }; + + // sécurité pour éviter les boucles infinie + int step = 0; + int max = map.length * map[0].length; + for (; step < max; step++) + { + pathMap.add(current); + + if (current.equals(end)) + return true; + + boolean moved = false; + + for (int[] pos : coord) + { + int x = current.x + pos[1]; + int y = current.y + pos[0]; + + if ((x >= 0 && map[0].length > x) && (y >= 0 && map.length > y)) + { + Point next = new Point(x, y); + + if (next.equals(previous)) + continue; + + Circuit element = getElement(x, y); + Circuit cElement = getElement(current.x, current.y); + if (element.isRoad() || (element.isFinish() && cElement.isRoad())) + { + previous = current; + current = next; + moved = true; + break; + } + } + } + + // Si il est bloqué + if (!moved) break; + } + + return false; + } + + /** + * Retourne l'objet Circuit à la position (x, y). + * + * @param x Coordonnée X + * @param y Coordonnée Y + * @return L'objet Circuit + */ + public Circuit getElement(int x, int y) + { + return map[y][x]; + } + + /** + * Retourne le type de cellule (Circuit.Cell) à la position (x, y). + * + * @param x Coordonnée X + * @param y Coordonnée Y + * @return Le type de cellule Circuit.Cell + */ + public Circuit.Cell getCell(int x, int y) + { + return getElement(x, y).getType(); + } + + /** + * Retourne le point du chemin à l'indice donné. + * + * @param index Indice dans le chemin + * @return Point correspondant + */ + public Point getPath(int i) + { + return this.pathMap.get(i); + } + + /** + * Retourne la taille du chemin trouvé. + * + * @return Nombre de points dans le chemin + */ + public int getPathSize() + { + return this.pathMap.size(); + } +} diff --git a/model/State.java b/model/State.java new file mode 100644 index 0000000..b2389c0 --- /dev/null +++ b/model/State.java @@ -0,0 +1,40 @@ +package model; +public class State +{ + public static enum DriveMode + { +// + NORMAL(2, 1, 6); + + public int carbUsed; + public int[] interval; + + private DriveMode(int carbUsed, int fInterval, int sInterval) + { + this.carbUsed = carbUsed; + interval = new int[] {fInterval, sInterval}; + } + } + + private DriveMode current = DriveMode.NORMAL; + + public DriveMode get() + { + return current; + } + + public int[] getInterval() + { + return current.interval; + } + + public int getConsumption() + { + return current.carbUsed; + } + + public void set(DriveMode DriveMode) + { + current = DriveMode; + } +} diff --git a/view/FenetreJeu.java b/view/FenetreJeu.java new file mode 100644 index 0000000..9c101ea --- /dev/null +++ b/view/FenetreJeu.java @@ -0,0 +1,61 @@ +package view; + +import javax.swing.*; +import java.awt.*; +import java.util.*; +import model.*; + +/** + * Fenêtre principale du jeu de course. + * Elle affiche : + * - le circuit + * - le classement des voitures + * - et ouvre une fenêtre de tableau de bord pour chaque voiture. + */ +public class FenetreJeu extends JFrame { + + private final PanneauCircuit panneauCircuit; + private final PanneauClassement panneauClassement; + private final java.util.List tableaux = new ArrayList<>(); + + private Runnable actionPause; // Action pour pause/reprendre, donnée par le contrôleur + + public FenetreJeu(Game game) { + setTitle("🏎️ Jeu de course - Vue principale"); + setDefaultCloseOperation(EXIT_ON_CLOSE); + setLayout(new BorderLayout()); + + // Partie centrale : le circuit + panneauCircuit = new PanneauCircuit(game); + add(panneauCircuit, BorderLayout.CENTER); + + // Partie droite : le classement + panneauClassement = new PanneauClassement(game); + add(panneauClassement, BorderLayout.EAST); + + // Fenêtres séparées : un tableau de bord par voiture + for (Car voiture : game.getCars()) { + tableaux.add(new FenetreTableau(voiture, this)); + } + + setSize(1100, 650); + setLocationRelativeTo(null); // centre la fenêtre à l’écran + setVisible(true); + } + + /** Met à jour tous les affichages à partir du modèle */ + public void rafraichir(Game game) { + panneauCircuit.mettreAJour(game); + panneauClassement.mettreAJour(game); + tableaux.forEach(FenetreTableau::rafraichir); + } + + /** Permet au contrôleur de donner l’action Pause/Reprendre */ + public void setActionPause(Runnable action) { + this.actionPause = action; + } + + public Runnable getActionPause() { + return actionPause; + } +} diff --git a/view/FenetreTableau.java b/view/FenetreTableau.java new file mode 100644 index 0000000..0114fc1 --- /dev/null +++ b/view/FenetreTableau.java @@ -0,0 +1,53 @@ +package view; + +import javax.swing.*; +import java.awt.*; +import model.*; + +/** + * Petite fenêtre qui affiche les informations d'une voiture : + * - carburant restant + * - nombre de tours + * - état (mode de conduite) + * et un bouton Pause/Reprendre. + */ +public class FenetreTableau extends JFrame { + + private final Car voiture; + private final JLabel lblCarburant, lblTours, lblEtat; + private final JButton boutonPause; + + public FenetreTableau(Car voiture, FenetreJeu parent) { + this.voiture = voiture; + + setTitle("Tableau de bord - Voiture"); + setLayout(new GridLayout(4, 1)); + getContentPane().setBackground(Color.LIGHT_GRAY); + + lblCarburant = new JLabel("Carburant : " + voiture.getFuel(), SwingConstants.CENTER); + lblTours = new JLabel("Tours : " + voiture.getRound(), SwingConstants.CENTER); + lblEtat = new JLabel("État : " + voiture.getState().get(), SwingConstants.CENTER); + boutonPause = new JButton("⏸️ Pause / ▶️ Reprendre"); + + boutonPause.addActionListener(e -> { + if (parent.getActionPause() != null) + parent.getActionPause().run(); + }); + + add(lblCarburant); + add(lblTours); + add(lblEtat); + add(boutonPause); + + setSize(250, 180); + setLocationByPlatform(true); + setVisible(true); + } + + /** Met à jour les infos affichées */ + public void rafraichir() { + lblCarburant.setText("Carburant : " + voiture.getFuel()); + lblTours.setText("Tours : " + voiture.getRound()); + lblEtat.setText("État : " + voiture.getState().get()); + } +} diff --git a/view/Main.java b/view/Main.java new file mode 100644 index 0000000..e6b5541 --- /dev/null +++ b/view/Main.java @@ -0,0 +1,24 @@ +import model.*; +import view.*; + +public class Main { + public static void main(String[] args) { + // Création du modèle (jeu) + Game jeu = new Game.Builder() + .defaultMap() + .setPlayers(3) + .build(); + + // Création de la vue + FenetreJeu vue = new FenetreJeu(jeu); + + // Lier le bouton pause + vue.setActionPause(jeu::togglePause); + + // Timer Swing pour actualiser la vue + new javax.swing.Timer(1000, e -> vue.rafraichir(jeu)).start(); + + // Thread séparé pour exécuter la logique du jeu + new Thread(jeu::run).start(); + } +} diff --git a/view/PanneauCircuit.java b/view/PanneauCircuit.java new file mode 100644 index 0000000..73a8b95 --- /dev/null +++ b/view/PanneauCircuit.java @@ -0,0 +1,80 @@ +package view; + +import javax.swing.*; +import java.awt.*; +import java.awt.geom.Ellipse2D; +import model.*; + +/** + * Panneau qui dessine le circuit et les voitures. + * Il se met à jour à chaque étape du jeu. + */ +public class PanneauCircuit extends JPanel { + + private Game jeu; + + public PanneauCircuit(Game jeu) { + this.jeu = jeu; + setBackground(Color.DARK_GRAY); + } + + public void mettreAJour(Game jeu) { + this.jeu = jeu; + repaint(); + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + Graphics2D g2 = (Graphics2D) g; + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + + Map map = jeu.getMap(); + int tailleCase = 40; + + // Dessin de la grille + for (int y = 0; y < 10; y++) { + for (int x = 0; x < 20; x++) { + Circuit.Cell cell = map.getCell(x, y); + g2.setColor(couleurCellule(cell)); + g2.fillRect(x * tailleCase, y * tailleCase, tailleCase, tailleCase); + g2.setColor(Color.BLACK); + g2.drawRect(x * tailleCase, y * tailleCase, tailleCase, tailleCase); + } + } + + // Dessin des voitures + Car[] voitures = jeu.getCars(); + for (int i = 0; i < voitures.length; i++) { + Car v = voitures[i]; + int pos = v.getPosition(); + Point p = map.getPath(pos); + int px = p.x * tailleCase + 5; + int py = p.y * tailleCase + 5; + + g2.setColor(couleurVoiture(i)); + g2.fill(new Ellipse2D.Double(px, py, tailleCase - 10, tailleCase - 10)); + } + } + + /** Couleur en fonction du type de cellule */ + private Color couleurCellule(Circuit.Cell cell) { + return switch (cell) { + case ROAD -> Color.GRAY; + case START -> Color.GREEN; + case FINISH -> Color.RED; + case YROAD -> Color.YELLOW; + default -> Color.WHITE; + }; + } + + /** Couleur de chaque voiture */ + private Color couleurVoiture(int i) { + return switch (i) { + case 0 -> Color.RED; + case 1 -> Color.BLUE; + case 2 -> Color.ORANGE; + default -> Color.MAGENTA; + }; + } +} diff --git a/view/PanneauClassement.java b/view/PanneauClassement.java new file mode 100644 index 0000000..756a97f --- /dev/null +++ b/view/PanneauClassement.java @@ -0,0 +1,47 @@ +package view; + +import javax.swing.*; +import java.awt.*; +import java.util.*; +import model.*; + +/** + * Panneau latéral affichant le classement des voitures. + */ +public class PanneauClassement extends JPanel { + + private Game jeu; + + public PanneauClassement(Game jeu) { + this.jeu = jeu; + setPreferredSize(new Dimension(250, 0)); + } + + public void mettreAJour(Game jeu) { + this.jeu = jeu; + repaint(); + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + g.setFont(new Font("Arial", Font.BOLD, 14)); + g.drawString("🏆 Classement :", 20, 30); + + java.util.List liste = new ArrayList<>(Arrays.asList(jeu.getCars())); + liste.sort(Comparator.comparingInt(Car::getScore).reversed()); + + int y = 60; + for (int i = 0; i < liste.size(); i++) { + Car c = liste.get(i); + String medal = switch (i) { + case 0 -> "🥇"; + case 1 -> "🥈"; + case 2 -> "🥉"; + default -> ""; + }; + g.drawString(medal + " Voiture " + (i + 1) + " - Score : " + c.getScore(), 20, y); + y += 25; + } + } +}