From 68ead7f2195f940e409229990cdb9e3a866f9bff Mon Sep 17 00:00:00 2001 From: karthikmurakonda Date: Tue, 9 Aug 2022 22:24:05 +0530 Subject: [PATCH] init --- assignment_0/.vscode/launch.json | 30 +++++++++++++ assignment_0/.vscode/settings.json | 7 +++ assignment_0/README.md | 18 ++++++++ assignment_0/bin/Cell.class | Bin 0 -> 625 bytes assignment_0/bin/Clock.class | Bin 0 -> 438 bytes assignment_0/bin/Infiltrator.class | Bin 0 -> 473 bytes assignment_0/bin/Main.class | Bin 0 -> 2077 bytes assignment_0/script.py | 47 ++++++++++++++++++++ assignment_0/src/Cell.class | Bin 0 -> 510 bytes assignment_0/src/Cell.java | 21 +++++++++ assignment_0/src/Clock.class | Bin 0 -> 342 bytes assignment_0/src/Clock.java | 11 +++++ assignment_0/src/Infiltrator.class | Bin 0 -> 371 bytes assignment_0/src/Infiltrator.java | 10 +++++ assignment_0/src/Main.class | Bin 0 -> 1639 bytes assignment_0/src/Main.java | 66 +++++++++++++++++++++++++++++ 16 files changed, 210 insertions(+) create mode 100644 assignment_0/.vscode/launch.json create mode 100644 assignment_0/.vscode/settings.json create mode 100644 assignment_0/README.md create mode 100644 assignment_0/bin/Cell.class create mode 100644 assignment_0/bin/Clock.class create mode 100644 assignment_0/bin/Infiltrator.class create mode 100644 assignment_0/bin/Main.class create mode 100644 assignment_0/script.py create mode 100644 assignment_0/src/Cell.class create mode 100644 assignment_0/src/Cell.java create mode 100644 assignment_0/src/Clock.class create mode 100644 assignment_0/src/Clock.java create mode 100644 assignment_0/src/Infiltrator.class create mode 100644 assignment_0/src/Infiltrator.java create mode 100644 assignment_0/src/Main.class create mode 100644 assignment_0/src/Main.java diff --git a/assignment_0/.vscode/launch.json b/assignment_0/.vscode/launch.json new file mode 100644 index 0000000..34cd2d4 --- /dev/null +++ b/assignment_0/.vscode/launch.json @@ -0,0 +1,30 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "java", + "name": "Launch Main", + "request": "launch", + "mainClass": "Main", + "projectName": "assignment_0_9a9b1a91", + "args": "0.5 1" + }, + { + "type": "java", + "name": "Launch Current File", + "request": "launch", + "mainClass": "${file}" + }, + { + "type": "java", + "name": "Launch Main", + "request": "launch", + "mainClass": "Main", + "projectName": "assignment_87438f", + "args": "0.5 1" + } + ] +} \ No newline at end of file diff --git a/assignment_0/.vscode/settings.json b/assignment_0/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/assignment_0/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/assignment_0/README.md b/assignment_0/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/assignment_0/README.md @@ -0,0 +1,18 @@ +## Getting Started + +Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code. + +## Folder Structure + +The workspace contains two folders by default, where: + +- `src`: the folder to maintain sources +- `lib`: the folder to maintain dependencies + +Meanwhile, the compiled output files will be generated in the `bin` folder by default. + +> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there. + +## Dependency Management + +The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies). diff --git a/assignment_0/bin/Cell.class b/assignment_0/bin/Cell.class new file mode 100644 index 0000000000000000000000000000000000000000..3a5d5c677625a1a48e9fc76c2234106d28b67bd1 GIT binary patch literal 625 zcmY*X$xho)6g@9?2zH!=c}VC43&0EV0Sp@=)J1?rsw}#DHcwz`?8q@l{0W<`yJ3S= z)T#?UfNw&Ga~(@6vk1q2a+nQ^DHW9y%bq zhbpENTKy<7C)Zbj$-d|yCe2(w4Rt)!StN0pwDXH-O!~fzx2w<`n|xrBahet4E|#%c z!wL(3r#{yCg@-me#AP};ORoy~p2)xRP{XuBgYfX%u^yE=&GY|w3jo)02kCVdnxjYt zbYzAd(ZMHDS-f6_AJ-{7^3qDyfy;WG-VtNTxc)DA{^lcE4~#09<=ZSORoKKkoNA7_ zCDz!Dc`VS1C+s{i7TG`H91$U$o!?mcyy^c$>+U=1zWs=`ADH$nS`o1dk#;ehOGq6J zcob%$RV}5?Wz5!g~$b%(t2T2;wJUD`28m_`#5-ujayJ)K8T;Swpt_5-Y_xoM*lI$s?ZZVw&>5PAzFp2EosGgMA%Az6#$hrJGgHiK(8-_8 zi@+O}2`<=8bUrHmXhBDs$1{PtPnTJ&uT7z(%H^{nDURuB^D6?YFlJ}7XBgg1PJQCS zs=A*%_6PhoP8Qm{+a=S2!`dX)A?8=x2(ZJ6sj;_K>ai9|ZucGjE1OEBQGpv|wQXA36goK1>p&_wzSVkPO?wE1VpRzI0m{|A$ew6VH z5X55c+;el!<9`2qegQbaZWSegxL4fj+*#?2ts)diC-OF7ecQ-NUrU?32lnURVRAWl$4tqy^;1Z7kNntffU^XdIi*(*8BmB2=yQu#ny z?eSt5x;yoCFwXtA^#Qv%#XUTjUDb|U24>no7Qk%b5 yD!1N{ys(*zRA$3)g{bxn47^Djq4DR4ES&tHakDYHE@+xZ1iUrG)D literal 0 HcmV?d00001 diff --git a/assignment_0/bin/Main.class b/assignment_0/bin/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..bf2752d7a223e7dcc36899bc0afc47d80629f772 GIT binary patch literal 2077 zcmZ`(&vR2%6#i~rl9#-^{wBp(l%fJ@C=C>7r43jhBB3coTB@a@zNW9~qxsQ!c?EG? zxWMU-mBR=N$GWf!7b=W}5r;p(z2l4<#~C*&8^#%TQor-UQ0ibNbMLw5*FEQa-+ezk z{O%rrL#XHoCCHzg+>!0ghgsLp(CQuly@rjsm1cN?T%a1C8lZ3 zR|{5Y!g3usKT?J>epUk-;wIW)Fta!3)D*&bDR+>SSr={BDl$VTIhE_mDnzBwackbL zCC{Y#8&b!u*J};NPaBgW1c>s?eUC%C8S$%yXSeajPSL)MtBp{6=CXV75eTy4>eZ0@f4X>Iw?k8Jts|DMh zIbL-yS?-LOPMFByB#UCKpzJwS&X`2W$yIq1BVyHQ6>Ky#9UY3|G|uRFeZ!>3F4sJ} zY+?-K46iQAbm{|ks_E0j$Rkp=RUS0RvAYtH5oYOI>(B{v2qoau_8JoT!u_e|N zwA>=e)%Fzh$=S+cd2}}Ck#5of{bKBO+M0Gsj(3^Uz2wYzb9@jE=~*B&XBUL00up%| z6U`Z?IOmDlkW=2C^$))3v}@PMPC7d4(2=A0Cy->CP(dJM&3PZoK^^CrZLGTJ7VP7W zJfx^Rj2`J0ot%TlCmujV9w4QNJU{M1u2IOGVm$S5m!HvU-a>AI8*c8+ zbbN1&q_o~Uc=2Q^$gN8X4zH+fcafg#x{bX9`eP~bSc*QDjJw!Bc^iELvAgJ}aB#p( z=&Kk=L}ZC_S;1z1uWNjpxr#%g8@kTH(2;vgqK0m){gjBUBAXD86_o#zDq%=cE<-oa z`Sb*c)DtkvYw^%$*zU)yputc1M1r*kzT*nE)GfSmxb@WMbgYLiuYDwj;hSh!h8`q? zy5nJAGkPVg;^B_vhris!X!jkQUBw$hlRAQ{{N91%)zC=%nz^x}*sNi3raU+{bTCGr0n-T0RG z{Ybw5%*?-GFMdZa?qeSw@H6!{<%j4~8v0cj2UUz8^sN|FDP&X+4y%5&sv!)ilQ`lt z?0piOw7^?9Fa4+!c$?hf(^OfXbpbT0LwJW3X=qmmSaX*$* z45bKr{fB)ONWd)q!Yn0&egAC}+7xVKcx+=ht1mHg0OfxHp8%Gi literal 0 HcmV?d00001 diff --git a/assignment_0/script.py b/assignment_0/script.py new file mode 100644 index 0000000..ed61763 --- /dev/null +++ b/assignment_0/script.py @@ -0,0 +1,47 @@ +import os.path,subprocess +import matplotlib.pyplot as plt + +from subprocess import STDOUT,PIPE +from typing import ByteString + +def compile_java(java_file): + subprocess.check_call(['javac', java_file]) + +def execute_java(java_file, stdin, probability, width): + java_class,ext = os.path.splitext(java_file) + cmd = ['java', java_class, str(probability), str(width)] + proc = subprocess.Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT) + stdout,stderr = proc.communicate(stdin) + return stdout.decode('utf-8') + +filename = 'Main.java' +compile_java(filename) + +# fixed width +width_list = [x for x in range(1,100,30)] +for w in width_list: + probabily_list = [x/100 for x in range(0,100,5)] + time_list = [] + for probability in probabily_list: + time_list.append(float(execute_java(filename, '', probability, w).strip('\n'))) + print(time_list) + plt.plot(probabily_list, time_list) +plt.xlabel('Probability') +plt.ylabel('Time') +plt.title('Fixed Width') +plt.show() + +# variable width +# p = 0.5 +# w_list = [x for x in range(2,201)] +# time_list = [] +# for width in w_list: +# time_list.append(float(execute_java(filename, '', p, width).strip('\n'))) +# print(time_list) +# plt.plot(w_list, time_list) +# plt.xlabel('Width') +# plt.ylabel('Time') +# plt.title('Variable width') +# plt.show() + + diff --git a/assignment_0/src/Cell.class b/assignment_0/src/Cell.class new file mode 100644 index 0000000000000000000000000000000000000000..3691f85e0352de4eb71f78cc2f06fd7da033bca3 GIT binary patch literal 510 zcmZ9I&rZTX5XQf43#FwXilBmjPe2dy0_sI#JcycLIC$G)qt)7)T1Y+5#Xo3Qre{PZ zGCGMbN63ys&N`@|Dqs!B>!mXFi8&^}*=hAvnfQdBsl6cb_lK9BpBzaqq^Ef8r#(Nq zj+04JfjYS8%B$ai(|-XRf?T^750inv6DWwKhFDiUVvW6M{1}ak1CA^^9tIn0NQcyT%L356HPX zRe`h-sLFyY!IV4-Y^FkV4JFj+HKBc>q8sEcVrfEGD)^Woxco?C+>j~`lzA>wHLUyq DM?z6c literal 0 HcmV?d00001 diff --git a/assignment_0/src/Cell.java b/assignment_0/src/Cell.java new file mode 100644 index 0000000..718188b --- /dev/null +++ b/assignment_0/src/Cell.java @@ -0,0 +1,21 @@ +public class Cell { + private double probability; + private boolean cellState; + + Cell(double probability) { + this.probability = probability; + } + + public void setSensorState() { + double random = Math.random(); + if (random <= probability) { + cellState = true; + } else { + cellState = false; + } + } + + public boolean getSensorState() { + return cellState; + } +} diff --git a/assignment_0/src/Clock.class b/assignment_0/src/Clock.class new file mode 100644 index 0000000000000000000000000000000000000000..ce1b6388ccc8d8ac502050d5e77429f29f682c9a GIT binary patch literal 342 zcmZvWy-EW?6ot>-pNu=MX8ma`Y$R@BUO;UEf*@KL1Uq-vAxzxtLYVkeHi9Bp_y9hX zcxI4PHh0b(&Uf$m{`vd@aE5)22(dzvBgH^a%&X^W+*aLed{fU&;{=0K+gW!mh)2hF z88(n9=p38K1?i;inIl?H8uhX^tZFeKzl@gydV(2L1sxs;V73{R9+?u_6c9^J%< z5Qj)Iq{s;AOy8@cQ&M2)G0Q$`bLMhMPLEeYef((+>UP)d6(%7!=TLb`cRWm_hX z9<8aQtf$643tJPCE3>kdoT^rl|H(OSPsAP{;_(Z_$ft1UbI(68Zt%3vd*YfDAE3g2 zNBG*YN9}H{3_8vj`C7BfwbcxYH-s-ey|n}a#?9XTpo;_2;+DC=-9P>j=fo`9VzGzq EUwhCx_y7O^ literal 0 HcmV?d00001 diff --git a/assignment_0/src/Infiltrator.java b/assignment_0/src/Infiltrator.java new file mode 100644 index 0000000..5089cbe --- /dev/null +++ b/assignment_0/src/Infiltrator.java @@ -0,0 +1,10 @@ +public class Infiltrator { + private int location = 0; + public int getLocation() { + return location; + } + + public void proceedForward() { + location += 1; + } +} diff --git a/assignment_0/src/Main.class b/assignment_0/src/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..be367dedbe674f413e34e08ec9d0c0d61558c368 GIT binary patch literal 1639 zcmZuy%}*Og6#tEP?X}m-r!in0l0XTyjROHvQov9eDAWW3sVOZ%inN$5-NfES%aVSa zqAC?q5ACgOq8=J9mU^k0s1SvUUV3TIJ@y~SCFe*{&}Mp?<$&@IYP|2j%lq8Cnr=?qeelkhC0*>)E&8GE!S8x9D$$*LrZ}Z zF|rC81mtm}P*4#;Bk#Y76p4xCqJkLhBWrzN7Ffkw;;=Is z&hoLVHw-stSR1yJb9L8XQ@e&&&_SlPVb%CyCx$xBdH@lQa7#RW8+~D&PQG_k7hcJpa6pU$j6PJ(Cl>21EHHwtq-sI9& z*fH&%d7{Q8f(*SltP=2qhPNfQ#`eplmHOv|{sSzIxk1>NhFDynw=)~vqntrc7o@GWO4py(a8F|m9?_Yl4B zQsNU#)HRuW;hn6Th0Fbmzle= zD3zbaw^I9C_K)Q5^8gzuC+GDMbQ8gxrn!UmG)LMfd}XNcE0`DjQR?T2QSNt;tK|0G zpxjlop)0k0nfNd2Y)a~T3}rec(^NI!mj(jSKzv(t>>;w0+(mRqIh2BjQs_`p_t3nw ziO?)JvT2v+rha~`OjE*2Z(`tlRn<7%?(Sjwq>Nju-dFq}IiODzoHAjA&uYZg?Nf?Ji`Sdxfg$B{$FR1DGU zIfgMYP1l_J= maxtime) { + isInfinite = true; + } + timeTaken[i] = clock.getTime(); + } + System.out.println(average(timeTaken)); + } +} \ No newline at end of file