From 1ebc5f94df1942e011708a08808e746764315c6c Mon Sep 17 00:00:00 2001 From: Ghala Almasri <AlmasriG@cardiff.ac.uk> Date: Wed, 19 Mar 2025 22:09:02 +0000 Subject: [PATCH] Added Q1a Maven Project Folder --- Q1a_24067844/.DS_Store | Bin 0 -> 6148 bytes Q1a_24067844/pom.xml | 43 ++++++++++++ Q1a_24067844/src/.DS_Store | Bin 0 -> 8196 bytes Q1a_24067844/src/main/.DS_Store | Bin 0 -> 6148 bytes Q1a_24067844/src/main/java/.DS_Store | Bin 0 -> 6148 bytes .../src/main/java/MagicSquareGenerator.class | Bin 0 -> 1697 bytes .../src/main/java/MagicSquareGenerator.java | 64 ++++++++++++++++++ Q1a_24067844/src/test/.DS_Store | Bin 0 -> 6148 bytes Q1a_24067844/src/test/java/.DS_Store | Bin 0 -> 6148 bytes .../test/java/MagicSquareGeneratorTest.java | 27 ++++++++ .../target/classes/MagicSquareGenerator.class | Bin 0 -> 2045 bytes .../compile/default-compile/createdFiles.lst | 1 + .../compile/default-compile/inputFiles.lst | 1 + .../default-testCompile/createdFiles.lst | 1 + .../default-testCompile/inputFiles.lst | 1 + .../surefire-reports/MagicSquareTest.txt | 4 ++ .../surefire-reports/TEST-MagicSquareTest.xml | 64 ++++++++++++++++++ .../target/test-classes/MagicSquareTest.class | Bin 0 -> 1689 bytes 18 files changed, 206 insertions(+) create mode 100644 Q1a_24067844/.DS_Store create mode 100644 Q1a_24067844/pom.xml create mode 100644 Q1a_24067844/src/.DS_Store create mode 100644 Q1a_24067844/src/main/.DS_Store create mode 100644 Q1a_24067844/src/main/java/.DS_Store create mode 100644 Q1a_24067844/src/main/java/MagicSquareGenerator.class create mode 100644 Q1a_24067844/src/main/java/MagicSquareGenerator.java create mode 100644 Q1a_24067844/src/test/.DS_Store create mode 100644 Q1a_24067844/src/test/java/.DS_Store create mode 100644 Q1a_24067844/src/test/java/MagicSquareGeneratorTest.java create mode 100644 Q1a_24067844/target/classes/MagicSquareGenerator.class create mode 100644 Q1a_24067844/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst create mode 100644 Q1a_24067844/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst create mode 100644 Q1a_24067844/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst create mode 100644 Q1a_24067844/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst create mode 100644 Q1a_24067844/target/surefire-reports/MagicSquareTest.txt create mode 100644 Q1a_24067844/target/surefire-reports/TEST-MagicSquareTest.xml create mode 100644 Q1a_24067844/target/test-classes/MagicSquareTest.class diff --git a/Q1a_24067844/.DS_Store b/Q1a_24067844/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..418fdb06de8034f48186d19c51bb4ad62248e7fe GIT binary patch literal 6148 zcmeHK%}*0S6n|5yY$@0k3ZjY0CXERP#PSgh;b1K_gcyZTf)K#E+b(6p?oPA2ZTSdE z&w3)^>L1`qPsXzcFP`<N2d^f2<fd;vYOA0pVhq`r%>3TIubugAXQl%HBwH<w0;m9> zU}G5V!tMlNe%6jjL|VEL39qpY4%o9cEgJT*=+F={5Hj$;F~HVtCscsq${m5W^-B%( zux;TEwvq2#Py^@yA3P||EX=2?e&C@c3J*ZXe6!^hd%({cFVJ&B4WsT?44X&2HY&E| z2kG<&66uJZJKw2vDsg2!ze(%)Ko6>ZR`*uf(;}s|(bRQg$ujE&H91Y)K(}1e;|W&D z#E`XzmRq9rEUmgFpXcU<Ly0M|f;zajH#RXjtc{OP><?>ulVj;&ZDRc9{(em9Pu-YW zC~Vn|OP}D#Q3&pDTzVun;VCMTk&<7u4ICW{l_slLlM^I|%?W;NPB7LL@9w#fP%kEW z6McQj{sDFHazX7g^x{_8V}qWiHubW0)hwt9AE!QBr0%?D)^N(pfw>*ztzC5W{+6&{ zmL9cCi#rvJNwy5U=!|EY?rPbyN^=_<z8NgH=__meU4iM$x*HVhv-iza0*ku-lIi(~ zE4t_DZrRN4tlPR_+H-D}1_5=JEgT^m6)%^s=tavdr*3}}WW`dMA)%>|5(*wH$)+Ze zEV{a5V(h#yq%!xUM}ccF1@~bIwqO?y;2AuJSMUzr!)N#cM}&|FiIW~OKrWFXa-EEj zTOu>k{CHPnB?%;hiu_V`c{E?7PDQwChb@mob2<4VRs5r`pAO!<WlKWlIkfZ_Z)LN+ z>PuE!=GF3^Yg4z37B;%`5a1H>pp1(s_;vA+tLSfEJotDzB56_Lr&BJh5;71naE2IQ z`-6s!VMby@Am2K$<5vL0D4MyTt}+EtlbDg%5QrWWB2p1WDv?(VBGS>W$+(QfhCq=H zL|#6Kd^3?Z6vE$*^)((2e2*7u*oO>+474%OA#|0U|9Ag<|8L6()sTUZfwRT{iRSXT zEY3=vt;goa&RPxIV{A-VTtgsF!A>5>TwzD?AT}=O)0l#ok=PK37L@Rh0H-1BLI(aR G13v&yD*?Cw literal 0 HcmV?d00001 diff --git a/Q1a_24067844/pom.xml b/Q1a_24067844/pom.xml new file mode 100644 index 0000000..715ac65 --- /dev/null +++ b/Q1a_24067844/pom.xml @@ -0,0 +1,43 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>com.example</groupId> + <artifactId>MagicSquareGenerator</artifactId> + <version>1.0-SNAPSHOT</version> + <packaging>jar</packaging> + + <properties> + <maven.compiler.source>11</maven.compiler.source> + <maven.compiler.target>11</maven.compiler.target> + </properties> + + <dependencies> + <!-- JUnit 5 API and Jupiter Engine --> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-api</artifactId> + <version>5.9.2</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-engine</artifactId> + <version>5.9.2</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <!-- Maven Surefire Plugin to run tests --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>3.0.0-M7</version> + </plugin> + </plugins> + </build> +</project> diff --git a/Q1a_24067844/src/.DS_Store b/Q1a_24067844/src/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..39aafda386b8bcd08046df1ee5d2a01043d65062 GIT binary patch literal 8196 zcmeHMy>HV%6n~c%a44mw9}t)#MMw;V7E%=<BnTl0MF<)-RcY0hU?*;B)xL{tr=?Vt zG6M?|D}MkJObAv67G@Y(SQ!|*!Ml&RO#>`QfZ(2V_dCCjJNtKcKEDJ2NWNJ+3y=Z; z0}Ds953BD8xAW2^38guLNH89X9;@0Ov+>&O^41E?fM!55pc&8%Xa@cU2Jp=0V*KFT zmsVYC1~dczB?J8ZkjBC>r?4eaygINFDF9+Gs)b-%eEK7%xdJh#uq6>SC`5)L%21+G z45BgzBE!+1Q~oW9G8~8)8T(Nq6P2M5m3WY}a0il;sB6uDW}uq^p1b#g4;HvU_vG)- z(RSvm5D^&r+3R6L<@vAdhUbRS`1l8s=;__J|A2A8=rfkeD{Q?SSy400TfqXqnqkbd z+ilC9b)EH!IeeAT$a1L@hyb_dpv&TIm)6*No;7JL6tQJ#Fp@^HVx~4X&z&0|O=l;w zTchdC3%os%o!r_=8Y7vpi_?`=&!_Bxd{m-d7tk-S<N6`C;^(P_RnNxz<Ib_ttDh}b znct8hmmcl5`K(Y-1Q@h5_WJRgw^ustwV&D>E4%x?%ZG@^T`LFFW3-Msc|Q?25JGf) zx-{Mlqd@rH!U^+H&*PN+k59_P1)P-Z#4k^ZdY;ZnQA)SErdA$#(q4HV+bb`5u<ua+ z;Q{l=z~I2p(D2AnGj+UT4%t?9wI1-*bd`B5$a_tvVh)73CW}=@OM$b7YjG}e?nPzy zKAHyi1WY@%J3FeGjRyJ*?<hp4*8|6)3-!RQO)W2nPBgcxJ-;Z%iX6X4ml^iY$D3+I zE~DYB6NHHKRuEXU?&LR?Jj-^xDVk?d#QZrI?~vb>=&szbsxGZ(E`Py!M@eRKr)0~7 zjBMc7{BXOakjzlachI*a6`9-(Wij9+T!fo23#)J+9>Y_31~1_qyoXQl8MX-_3DQUU z$x(8QoFb>m8FF4mCfd8|gz8CwIBequ*|~vI{Gg6)yEo8wq4*-+Kx&?SwzGl0XYbrV zX+D13cgF_O=RfC0i)NskfgY(!@%;bVkAMH~4%8aWfM(#IVSw}&%7r{WPWxEj`(!-V xPGh-?g$ws<NfaSiiF6!Mq~nP3ABNaYqbrZeDQrnZ4T}CDK+vEo&A@ME;2RHjM>+ri literal 0 HcmV?d00001 diff --git a/Q1a_24067844/src/main/.DS_Store b/Q1a_24067844/src/main/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..ab00c14bea7bad79a276163c149cfd05019dcf3d GIT binary patch literal 6148 zcmeHK%}*0S6n_I%wp8p21<}(cjfMka0fR9dTuTihMj<Rgh+y4qm$I_E)9h|rfspiQ z^hDy-Kfr&$c<|)Gi)TH0@#?{&2NQks(NaY{n#Sx)W`1wq$IP4Ge#{O4kbJE?37`Ui zf{kIKAG_ZO^RsqLdZdNr5jMvB@=~rAMgd+Yjz!0Yn1PsqZexJGy9sy*Ce*?F>HWQf zHV^Dh|AI?PmP;+Pu@A-#Y!lzPpw=;t)d;IH?v+(_oiNJfK9HW?#EFxAN}rNaHjQoC zFd{Rmg?Tf$$F5c=b*+|eTC0xTD5{w`>PM#I+W}8-$~J~<+;#jiZRBaqFNZwW5Dq1& zB#Y|k{{GZdZd{w5nLZfT_OCJh%Jj^^K~fpcUY=bp?zo;$pYV!-;CGA5fW#I&MWxM4 zIV`yr*2jX|MyFJlizLrli~QJHWU@bXYT$HQJ(C_x4-I98N7T`CMRmwBOFNZ-6+TB@ z8sy!YT~yN{E`Om!{iVRJ<FeNx`%z>#d*~YcC1Kev-#;>~>{c-*b7bIy&Ih*b->U>p zd2wqiw4=2SeSL$^71`c`zeRC;Hs4}3a;P7!+Chl8ZU%wrSM2=mrfXWZyXfa>6j5)@ z!3tSbd^n?OmK?v5z5YcImdxs7LQ^3t6x=j2Elna>@lDUh*d<}e>bImvfeSDTw_z1_ zU=I%AIlO?E@DAR?C-@9s2_ZcsMFz+SIZMXKB{D&-ip-wY4LmPLl0bA++V{$>Od2KX zRfY57<4&JP3kCVGDueysULU@B%O31@u1Cv%^;fq$$JW^t?cBN%_%8J;XlvEU{9Pil zBqh})^~7bw48#m{4+HG`pkZUEOKb|{pAPK!5dg9MyN^2iHDEcKL|tN2AbL=UNJSK> zL>@7SNJqOS<8+Blfg&A<JbVy2Gm$40!e__vH69Lp9}sHX#|*>_bTH5>bd~M@H}M_* z!}-4>BUWPuVg~*<21ue{6!N$#xwjr$AKPm+Y!9$8VR21?JOw+s9dm_k#iQ7`pig58 XqAsy15G^S2j{v73?qUZ1DFZ(M8-nNY literal 0 HcmV?d00001 diff --git a/Q1a_24067844/src/main/java/.DS_Store b/Q1a_24067844/src/main/java/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..6f4d6bc37d47bd82e8f1669db9616a2a63a55d58 GIT binary patch literal 6148 zcmeHKJxc>Y5PhpD0yZhtYAZ{@f3Sv#SXc$DO=1w`$dSZY-#<U!+gU$OuMtE<W?=Ts z?tJXtgWC@PVZ6IL14aObRAG?OBO2~??Ui6*$Tb$2VvQYU*z^?oi$hxbF|N7ddpzLd z`j@!G5-aM4-Y3+=Q$|$mZLz(o>czaO=gb#*=hTxn3oYR28#NzU@fovE6>r`vwr#HI zjWgg3I0MdrGw>4(@XVGB4-CC^2AlzB;Ee(850NTN1slV>b+FO(S^j}gLR;5iVJw&m zHiq<2f~68IHIyetuyl^c5|;`#hL(<yXJ(x;^Xua!<k>kMb2vgW^wt@02D%LFTX&@M z|AN0v?<2pP;yq`;8Te-mgu!Gw8S|sc+4|-4bk;`dEmfkpMh1m;=Mun<_L0NvG=G%M YxKyw)R27ZqbfRAbG9lhL1HZt)3$MsFJpcdz literal 0 HcmV?d00001 diff --git a/Q1a_24067844/src/main/java/MagicSquareGenerator.class b/Q1a_24067844/src/main/java/MagicSquareGenerator.class new file mode 100644 index 0000000000000000000000000000000000000000..74f3815d309c80d2103868567a9bd63ebaf7eb3d GIT binary patch literal 1697 zcmZuy-%}e^6#j0q$!@|zfe;E!Qny7k1e;K>sY0Mt?2l+5XbMQtjtkks){w+x!&smD zSM<Sg>H{;r*|DM1j=brEe}d2c5$e?9cQ>Jgna(En?m73I?|kRSP5yZK>;S-Jd=Z3( z@c;(#j*6JvF9f+H14v;)!$lR7K}_M@ATA*-m&+>NlZWpIp<`OZj8tZ%Fsors3Rk3X zRW2W>_)wzFYxqd+*94Th{hcKsvI744Hx08!!MnaL#f)9HojIDsvtujV<|{=Wp32!} zYq7DjVbyM#8zpK&TUObsnU1w!ZrPiKBapas>Ml6u=GO~mwQZ{w?RvFj-dAy*h&!fT z78s1L=kA%iW~yYCw^9YCW|y~Sq;s%PY1B5Y>$Z$C+<|_h6|hoEN<STEF{0xPB08do z={S!O6*qL;1k+GPr;3I^?{S3u#yxA(QSq^kPmoiwpkonv9ZMJy=yUBFj$KL>Hq9~< z)A1=jlQ9Yc6W7X)RWr=8Q7IM;o5B{wyOo;ZY+J^T%-?8L(U5hWHgw#=vW^w33QT3o zyJpFje$|GPG?q%1S+@+U1!+_(b=$Fbtxo8qWJUkav8LlT)&&M$R|d)M4S}IxyD(PK zaLtTXGp2Qn%G^A%tsR9Z+^;*<4*OkcI0E5T6YNTAi5+m*2g}@<IjV@;n`|p#0hNg~ zto&WsyzE#<_u3Y83%P|niN>L-N^JUN;vHV?o_CHxt4T9$?2|A=S6!SEr^h2l=$Ly} z*7g<mp>`DdcOJ;$^0^3feGL(J__odZqV=uAj98)g*lmtdnKD}t@65Q(os{J1k#!d5 zc)v7WX%8Qcru)X}<gP%-esMJ@U4@qxz))fzA`y84Pa+ce4PMU^D2XO~Kl4lw4aD<t z)#xAK6GRAIIL%w_kptgGJ0O~$R+cxD_yrzcX;ztw$v64k{t<cZN@Ow`%SV)=)O{tF zYFde&5Pi}ttW1V|$%oLxN+#@^-Gd%cTIQJtUa@!hlceTxsU=AT=q0T_456R85GF8y zD<qvG$vm~oEW;h17g>ZiX&r*{5?w-w|9DNsKhXYVenL)aJC|q7BtXLzNhUXbFzcO* zMIRwM9-Ew2hLvgGu<s!4_omgb8umZJ=&&!WCezwu`1@7mS7>YAu=W&zLKDH&2Pz5w z$)hH^T=Gwk$)APFDCbD`Jd%t)&pk^XdFqz&wo5iC$p%$;g*ZeQnu<YJQ1KQ&LI8gw ze#j~ao)9fSzxb;>yzCip=Q;GX$LQWiPfn6N)kN=j6MYX6l45@oA&LX5dxw8<56?z@ zRpkc+qu;~7hn^#oy~E$1V{k3HkJF1%H$=A!O$;CBlSVhAB}gXaw&4seGNVZ{nxgg+ pwQ0=qujVFZ_|ulb8l^8W=jPc1<psJ_=x1M`Uj&)K7_mG^{1460X_Ei| literal 0 HcmV?d00001 diff --git a/Q1a_24067844/src/main/java/MagicSquareGenerator.java b/Q1a_24067844/src/main/java/MagicSquareGenerator.java new file mode 100644 index 0000000..9f6bfe8 --- /dev/null +++ b/Q1a_24067844/src/main/java/MagicSquareGenerator.java @@ -0,0 +1,64 @@ +import java.util.Scanner; + +public class MagicSquareGenerator { + private int size; + private int[][] square; + + // Constructor to initialize the magic square + public MagicSquareGenerator(int size) { + this.size = size; + this.square = new int[size][size]; + generateMagicSquare(); + } + + // Generating the magic square using method in coursework brief + private void generateMagicSquare() { + int x = 0, y = size / 2; + for (int i = 1; i <= size * size; i++) { + square[x][y] = i; + int newX = (x - 1 + size) % size; + int newY = (y - 1 + size) % size; + + if (square[newX][newY] == 0) { + x = newX; + y = newY; + } else { + x = (x + 1) % size; + } + } + } + + // Display the magic square in a formatted grid + public void display() { + for (int[] row : square) { + for (int num : row) { + System.out.printf("%3d ", num); + } + System.out.println(); + } + } + + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + int size; + + // Input validation: Ensuring the number is a positive odd integer + while (true) { + System.out.print("Enter an odd integer for the magic square size: "); + if (!scanner.hasNextInt()) { + System.out.println("Invalid input. Please enter a positive odd integer."); + // Consume invalid input + scanner.next(); + continue; + } + size = scanner.nextInt(); + if (size % 2 == 1 && size > 0) break; + System.out.println("Invalid input. Please enter a positive odd integer."); + } + + // Generate and display the magic square + MagicSquareGenerator magicSquare = new MagicSquareGenerator(size); + System.out.println("\nGenerated Magic Square:"); + magicSquare.display(); + } +} diff --git a/Q1a_24067844/src/test/.DS_Store b/Q1a_24067844/src/test/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..34bb422410b4719753196e8ac792a538dc850208 GIT binary patch literal 6148 zcmeHKO-vI(6n;~xY^m543Zkb?8WRtw<tG}#!CGnvF$$psA%JzaUCPStPP4mh1wzuR zdLr@a)r6Bb<Jp53&w4Umyn68HP2c>qtRfzTn4M(idwqZN=G*Sf4gipRy)puz0)T>@ zVY~;2KQv}%{ZNZZ4T~cz$MpPMw(bWW{*E8=jua6C5d$ZU0ru|3;SuQ20R5Nu_a5pT zFvIp4o0bim8mPk!gM32V|G^tdp*%*@uSvf*M$NYTAe;S2VqNi5r@NJIC8?|xH)yjM z=t14j>)s0cwLqzDv}N5`w9IBnO;1rb&@I>Wcz{(g(Pj0%<yL4jPwQ^Q=dnd$P!dX_ zqz>)ujE+wXYhz>MyTjVf#AtR{8y~yAyPHr3GS?>OOPjXi(x<#)Ah>Vw)+@0M&rs;_ zQt`{Sf%P%xj?yYO<RZ!Q_98#G7n$fup6NZCQqQIOQvLnufkAcXLP_m6^zvraV}(yq zn|gV>ZkE)PkISDaQ+LiY8@TMHz<eAOt!*^*{T489RvsLv7Pe~WlRi-Jq|=^hx+_)B zs?4sh`)05dl9yNcT!HD#xa$=2v-xIgfkj<^(e!-8W!>|1w`%6M)@<D{?O8WZgMd0q z7FNir;^~Sty==MF%*}6tutX+zSx72mgn)-ex-Cg03$E^%=sPDAncN*|QQ#6x!d+N| zP1uG#cmezH8s5VP_yS+yJ0T=SlBAamlJn#;xk9dz8zM5+et;KcCJ7{mLg!i8)sbSE zI<=5b$L7#NLH=2lCoki#_TIj`6^?ai<*)YI#?iSOMbEXVTg80sIzuHKw<t?elE+<0 zG=IcE#K4JTfb9<&c7{2LErERNz=2-@5IdjyDC4IAkI^LNB(?<dP|PWA4@8C%dBq?i z9PJu&N6blV2^8T#L^u#RGm$qG!e_@gjk^Os2ZR`n5d#qeAqKjHtg`d}Hon70-2X!n zkr*)$G4Q`JK;ngBA&;w)XX~N$v9ngg{t!EB%&#Sohu|QOV=l0xcnCXhXw#U0n3LEN Th#G9shXAJ`8X^Y%DFZ(NX%Xl@ literal 0 HcmV?d00001 diff --git a/Q1a_24067844/src/test/java/.DS_Store b/Q1a_24067844/src/test/java/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..fb4b9171541e7de387ee5fe4ac632a4284b3f2d2 GIT binary patch literal 6148 zcmeH~ze)o^5XQfWDFQYrZG?RQ5qyIsM8v`>K7dIKVhA2aV||^k;#=xBe-w|4t%c6O z?C*AVW|#Yln_B=f+1;K2V*n$%60bV+P1n_XHi(Fjbndal43F4hj%_b{e?V)Gam9)| z+;{3%xWEbz^etDP(U8}iJ@NSzYsOwMzuYv-#im(s7al)2A>ZD^_8*whR3H^d1yX@j z;GZj?y_YsRbmo`}qynkHmje2ID0F2FwodzWaIh-?Ib_(3&vus}iw4LVY@LkI#7jvp zmAGPvmor`>uLfJEmqYAi?h_|V+)%_$XS`TCq&jm<1yX^o0tY@FYyUr||8W2B7Ue7z zNCp0s0y3P=rW3wW^w!?XX|FBx8~Ud)*U~vyD<-WKbE2*I=v!XVXRg;^>$Gylt(?ps N0o5ff75EJWJ^&=oB**{& literal 0 HcmV?d00001 diff --git a/Q1a_24067844/src/test/java/MagicSquareGeneratorTest.java b/Q1a_24067844/src/test/java/MagicSquareGeneratorTest.java new file mode 100644 index 0000000..0b7aca6 --- /dev/null +++ b/Q1a_24067844/src/test/java/MagicSquareGeneratorTest.java @@ -0,0 +1,27 @@ +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + +class MagicSquareTest { + + // Normal case: A 5x5 magic square should be generated with no issues + @Test + void generateMagicSquareNormal() { + MagicSquareGenerator magicSquare = new MagicSquareGenerator(5); + assertNotNull(magicSquare); + } + + // Abnormal case: Negative size should throw an exception + @Test + void generateMagicSquareAbnormal() { + assertThrows(NegativeArraySizeException.class, () -> { + new MagicSquareGenerator(-5); + }); + } + + // Boundary case: A 1x1 magic square should be generated with no issues + @Test + void generateMagicSquareBoundary() { + MagicSquareGenerator magicSquare = new MagicSquareGenerator(1); + assertNotNull(magicSquare); + } +} diff --git a/Q1a_24067844/target/classes/MagicSquareGenerator.class b/Q1a_24067844/target/classes/MagicSquareGenerator.class new file mode 100644 index 0000000000000000000000000000000000000000..5843feb21a16d5416c86f8923590a5a63bbdad2c GIT binary patch literal 2045 zcmZuyOLNm!6#lLyM~<TKh~to82LzPVIK>W08`{K9AC!k%Cx#kALnuYDg(Gle*Oqy7 z&97k5>A)g0-IXbZDN}asqCcUlF1qS3XgiejyOK-H3?u7aoyR@r`_4I%e|_=eGXTeN zLq`Pj{TM-3!?@gYI+ulhypIne_)x<~I!@qY9Vc;0E~hn|k;c3Z1D{0jsZ<uEuo%IT z6pB(fE0=Q`K9kW(5uBI%1p&3?d~FMeyg*;;tG3mopscP+G3&UFw?LO<{>U=76ZHy> zI}46$FSR$;?B;oEtwzmIp<cFX%U08oa#yK(>rP8xq_AjJopQ;KeA;&HrsdU}^8(Ro zAlN;2W={H<T>IANOvr78&>Y^kdEXHjEO}P>#-i2eX3;86t5LIPQQY<h*Jk~eKxj3u zVTu7ZEXO5=<Z9u%b<@h!EVr5|c}>Ty&ii?+W|bJDuQ3Z~t+M43FYUqUw&&C`r9epn z0~_1K1oTq9-7MRu99fXD9!@VgrzHdf`!Hc(FX9Fg7&mYj6B?EcT!bWic&1_s?Aiuf zT)S?UJq;@cE@4%}WdmQ}ih(aNA+X!`>xE_DD*PO40#hel&u*HQYt}0j)1gqMc&*+v zy>;94!J9$DO*sN{rhzgl25ejtn8~|0t(qgxHQHX<JX^D^mTlTWNV8FIIi7RV?hT!m zsCd4LbpsBr3k<)m46*|I1xEF5VeE?OyP3g=%o#W;x%Jebbf@LnvbXiNClCvo;nXu{ z*+-Avw5<)cBPfR7;e5cAEhLAwT_m3oj&RQmbUox4`Zatt8b`k&WAj`#*>kEpIla>o z^k=>s`_(XvuK96loWYPB#BJ<(S=N`>N4r^gzSkf}H0(#<(boWxc75GyE!np{GV<S^ zOa5zfo5FCimvI+6A-O%?c^u$ZAi@t%h!>~Qf8t<rS0QApxSEtML!k#SntBY8ia$aq z6_5W6CG-ets)O+Nw1pTAj2Gq_;rV`EI-(fB9)5cc`ZhlX4&e<-jOOQLb>w>xWD+4} z>Z8q8vZ)^s3fFS#!nk~r_xb}AxvTN%#CS2TR;2E#TpF`#;uSG0-D2u=ES$avBc^6! z;oK&SxEi=;?<!(*>pKZs@nNS46WB$_y9sNEx+tbF%n$1b3M5dZ_5$Hvp}oQaNjeJz zI)yaeWZ_hL?njbOVMbcP5k4uBMwe`eZ&!*s!3>u%$)^zBqCE=r1qOr={~|BM--!If z07AY5K|Sz0ll0SZSrRHtKFcW!<B9voPmWK|sblI~cr5&EwojSWVp^>4J`RtCV_JGP z@(_JPn)(wWD@rW#1pTEB^ow^jlKzdR4hH-JJlQV5K4{ExfRqoC(jorG97LXdDN=WV z6eVGkl+uXtj<dtVm`8>MP$jx9O-U&&Dd`#%A-3oo(J<l*8jkTN1n?J<Tdb0xh5r4R z#!Q#(pUfcRU3m&)<sk+iV@E+!+1bIa$qshkLsW`G9YiS(U)<dKgL^EO2shMkp(nmU z-zIka@3Oh|%TtW3BpzeWlGKgz*wGHgwpq_&kl9iMlkpqA7stqSntW%deTUjv<oLII zhFs4f%f{yT1zzy0kqVIFZTf)`O7uNW9vNQpT?+BUAl~JyD}JkYKz)t@4aUCb7!o=? K-{ZLu=Kce9G^f%4 literal 0 HcmV?d00001 diff --git a/Q1a_24067844/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/Q1a_24067844/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..23cd3a4 --- /dev/null +++ b/Q1a_24067844/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1 @@ +MagicSquareGenerator.class diff --git a/Q1a_24067844/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/Q1a_24067844/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..267cef7 --- /dev/null +++ b/Q1a_24067844/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1 @@ +/Users/ghalaalmasri/Desktop/cm1210 coursework/Q1a_24067844/src/main/java/MagicSquareGenerator.java diff --git a/Q1a_24067844/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/Q1a_24067844/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 0000000..445f820 --- /dev/null +++ b/Q1a_24067844/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst @@ -0,0 +1 @@ +MagicSquareTest.class diff --git a/Q1a_24067844/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/Q1a_24067844/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..23c1831 --- /dev/null +++ b/Q1a_24067844/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst @@ -0,0 +1 @@ +/Users/ghalaalmasri/Desktop/cm1210 coursework/Q1a_24067844/src/test/java/MagicSquareGeneratorTest.java diff --git a/Q1a_24067844/target/surefire-reports/MagicSquareTest.txt b/Q1a_24067844/target/surefire-reports/MagicSquareTest.txt new file mode 100644 index 0000000..599f640 --- /dev/null +++ b/Q1a_24067844/target/surefire-reports/MagicSquareTest.txt @@ -0,0 +1,4 @@ +------------------------------------------------------------------------------- +Test set: MagicSquareTest +------------------------------------------------------------------------------- +Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.015 s - in MagicSquareTest diff --git a/Q1a_24067844/target/surefire-reports/TEST-MagicSquareTest.xml b/Q1a_24067844/target/surefire-reports/TEST-MagicSquareTest.xml new file mode 100644 index 0000000..fdc43f4 --- /dev/null +++ b/Q1a_24067844/target/surefire-reports/TEST-MagicSquareTest.xml @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="UTF-8"?> +<testsuite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report-3.0.xsd" version="3.0" name="MagicSquareTest" time="0.015" tests="3" errors="0" skipped="0" failures="0"> + <properties> + <property name="gopherProxySet" value="false"/> + <property name="awt.toolkit" value="sun.lwawt.macosx.LWCToolkit"/> + <property name="java.specification.version" value="11"/> + <property name="sun.cpu.isalist" value=""/> + <property name="sun.jnu.encoding" value="UTF-8"/> + <property name="java.class.path" value="/Users/ghalaalmasri/Desktop/cm1210 coursework/Q1a_24067844/target/test-classes:/Users/ghalaalmasri/Desktop/cm1210 coursework/Q1a_24067844/target/classes:/Users/ghalaalmasri/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.9.2/junit-jupiter-api-5.9.2.jar:/Users/ghalaalmasri/.m2/repository/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar:/Users/ghalaalmasri/.m2/repository/org/junit/platform/junit-platform-commons/1.9.2/junit-platform-commons-1.9.2.jar:/Users/ghalaalmasri/.m2/repository/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar:/Users/ghalaalmasri/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.9.2/junit-jupiter-engine-5.9.2.jar:/Users/ghalaalmasri/.m2/repository/org/junit/platform/junit-platform-engine/1.9.2/junit-platform-engine-1.9.2.jar:"/> + <property name="java.vm.vendor" value="JetBrains s.r.o."/> + <property name="sun.arch.data.model" value="64"/> + <property name="java.vendor.url" value="https://openjdk.java.net/"/> + <property name="user.timezone" value=""/> + <property name="java.vm.specification.version" value="11"/> + <property name="os.name" value="Mac OS X"/> + <property name="sun.java.launcher" value="SUN_STANDARD"/> + <property name="user.country" value="US"/> + <property name="sun.boot.library.path" value="/opt/anaconda3/lib"/> + <property name="sun.java.command" value="/Users/ghalaalmasri/Desktop/cm1210 coursework/Q1a_24067844/target/surefire/surefirebooter-20250315030338681_3.jar /Users/ghalaalmasri/Desktop/cm1210 coursework/Q1a_24067844/target/surefire 2025-03-15T03-03-38_592-jvmRun1 surefire-20250315030338681_1tmp surefire_0-20250315030338681_2tmp"/> + <property name="jdk.debug" value="release"/> + <property name="surefire.test.class.path" value="/Users/ghalaalmasri/Desktop/cm1210 coursework/Q1a_24067844/target/test-classes:/Users/ghalaalmasri/Desktop/cm1210 coursework/Q1a_24067844/target/classes:/Users/ghalaalmasri/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.9.2/junit-jupiter-api-5.9.2.jar:/Users/ghalaalmasri/.m2/repository/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar:/Users/ghalaalmasri/.m2/repository/org/junit/platform/junit-platform-commons/1.9.2/junit-platform-commons-1.9.2.jar:/Users/ghalaalmasri/.m2/repository/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar:/Users/ghalaalmasri/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.9.2/junit-jupiter-engine-5.9.2.jar:/Users/ghalaalmasri/.m2/repository/org/junit/platform/junit-platform-engine/1.9.2/junit-platform-engine-1.9.2.jar:"/> + <property name="sun.cpu.endian" value="little"/> + <property name="user.home" value="/Users/ghalaalmasri"/> + <property name="user.language" value="en"/> + <property name="java.specification.vendor" value="Oracle Corporation"/> + <property name="java.version.date" value="2021-10-19"/> + <property name="java.home" value="/opt/anaconda3"/> + <property name="file.separator" value="/"/> + <property name="basedir" value="/Users/ghalaalmasri/Desktop/cm1210 coursework/Q1a_24067844"/> + <property name="java.vm.compressedOopsMode" value="Zero based"/> + <property name="line.separator" value=" "/> + <property name="java.specification.name" value="Java Platform API Specification"/> + <property name="java.vm.specification.vendor" value="Oracle Corporation"/> + <property name="java.awt.graphicsenv" value="sun.awt.CGraphicsEnvironment"/> + <property name="surefire.real.class.path" value="/Users/ghalaalmasri/Desktop/cm1210 coursework/Q1a_24067844/target/surefire/surefirebooter-20250315030338681_3.jar"/> + <property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/> + <property name="java.runtime.version" value="11.0.13+7-b1751.21"/> + <property name="user.name" value="ghalaalmasri"/> + <property name="path.separator" value=":"/> + <property name="os.version" value="15.1.1"/> + <property name="java.runtime.name" value="OpenJDK Runtime Environment"/> + <property name="file.encoding" value="UTF-8"/> + <property name="java.vm.name" value="OpenJDK 64-Bit Server VM"/> + <property name="java.vendor.version" value="JBR-11.0.13.7-1751.21-jcef"/> + <property name="localRepository" value="/Users/ghalaalmasri/.m2/repository"/> + <property name="java.vendor.url.bug" value="https://bugreport.java.com/bugreport/"/> + <property name="java.io.tmpdir" value="/var/folders/ny/94znt2hs7tlgk2swz46c4ylh0000gn/T/"/> + <property name="java.version" value="11.0.13"/> + <property name="user.dir" value="/Users/ghalaalmasri/Desktop/cm1210 coursework/Q1a_24067844"/> + <property name="os.arch" value="aarch64"/> + <property name="java.vm.specification.name" value="Java Virtual Machine Specification"/> + <property name="java.awt.printerjob" value="sun.lwawt.macosx.CPrinterJob"/> + <property name="sun.os.patch.level" value="unknown"/> + <property name="java.library.path" value="/Users/ghalaalmasri/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:."/> + <property name="java.vm.info" value="mixed mode"/> + <property name="java.vendor" value="JetBrains s.r.o."/> + <property name="java.vm.version" value="11.0.13+7-b1751.21"/> + <property name="sun.io.unicode.encoding" value="UnicodeBig"/> + <property name="java.class.version" value="55.0"/> + </properties> + <testcase name="generateMagicSquareNormal" classname="MagicSquareTest" time="0.007"/> + <testcase name="generateMagicSquareAbnormal" classname="MagicSquareTest" time="0.001"/> + <testcase name="generateMagicSquareBoundary" classname="MagicSquareTest" time="0"/> +</testsuite> \ No newline at end of file diff --git a/Q1a_24067844/target/test-classes/MagicSquareTest.class b/Q1a_24067844/target/test-classes/MagicSquareTest.class new file mode 100644 index 0000000000000000000000000000000000000000..25b1913d8e16314c945ebfbd6f2db2ec74adbc05 GIT binary patch literal 1689 zcmbVMX-^YD7=ETy7PbqN0v>oF7HL6TZ`67f;(;kOu}zI1r|nP{w>x#ai{QWVlSC7L zfbk!h7~k2g>=Fx6n{;R9y`JYiX1@LW{1w15R&)&GtcG(s5;(781{XBUW=J=$4mk~Z z4GRo|_btcr9x@E%@->F!s%#2|v6AJ8vfr)?x611_Nirqb;C79>mOA%@NpI8YGK`nj zdCO{4-uc`WRnhed45wPc5ia*cOjVX{o7)Vjc4W?QJnsE0^pdU$@yd5Rt1W6)*CNcK z<4BKtmUIa6Oi8*ebIT|0^zB%la82H^%pUsbKIp}|)5GtlU6H=i<nAs**5>VclV^_z zk-f^GKiO%BPC!S)BAqMJcN^lVrK)u{mi2y0irbYfzReBjNHI+IGg7+C8kP)Pfk|YP zy=il&WtK&Yvfma(*X6qv>x0-Qz>r>%((8II@2m@NQ#QL}gSeVTik52zuH%M*o47@N zjX^3p<QW0HtZ#`1i6$aZb<>sa!vRR<*3^K^^sjrd+ZArFHzPbal%-epZEE*at`tQK zK??brj@ww)F@!q|n%EHy-=o4U<?@GgcEfiX3c!34*eX&qBSwf7@T9S*#GzJgQWpLp zTt3EgKl6fyy9Vyzp@EaCYqL=<ma{G23bPc<3l*Mk@P;SV45ix9NyB5hW+f@#`W+&? z=Fq(es0kwcJx;h6FKpp+?lf)D&4!MJ7`2M$T23o2IpA2`?TG(VhLA`5#%t7rUFEi2 zp&Lk*Dl*LdQJ;SKFq}Kuj^3ytdcoB182#zOfQm;ulUAmr3!lI~(k6is`VI!dBt~g( zga#NxnohttIVS?=7Z{)&F!}|FH$$H=P+HtWGKw-vdJya|0gjNDigrBo=tUbQIvGq5 z!X)Vw>J+WY>NmzcvR4F+%(2g8fIVohBLwvvgLtJVM#R<VML!tx#D2^JypxCVK1sY! z5%1~0<(<~mOcNtj*!duLAf;-P{y`uCZ5EU_q&-e$$q)pPq!g#g;WX_NID-eY>Le@R T5$==4MLMfCWXWa@moWDW5iFvq literal 0 HcmV?d00001 -- GitLab