From 982155e4858dfe18b2cd2c3d6b62a17e1d4e2662 Mon Sep 17 00:00:00 2001 From: VasaviKashyap123 <65177128+VasaviKashyap123@users.noreply.github.com> Date: Thu, 16 Jul 2020 16:38:06 +0530 Subject: [PATCH] modif --- .classpath | 6 +- build/classes/.gitignore | 1 - build/classes/controller/WebServelet.class | Bin 0 -> 280 bytes .../classes/service/FlamesCheckService.class | Bin 0 -> 1846 bytes .../testing/TestFlamesCheckService.class | Bin 0 -> 1257 bytes src/controller/WebServelet.java | 5 + src/service/FlamesCheckService.java | 89 +++++++++++++++++- src/testing/TestFlamesCheckService.java | 52 +++++----- 8 files changed, 116 insertions(+), 37 deletions(-) delete mode 100644 build/classes/.gitignore create mode 100644 build/classes/controller/WebServelet.class create mode 100644 build/classes/service/FlamesCheckService.class create mode 100644 build/classes/testing/TestFlamesCheckService.class create mode 100644 src/controller/WebServelet.java diff --git a/.classpath b/.classpath index 2846539..20c137d 100644 --- a/.classpath +++ b/.classpath @@ -8,10 +8,6 @@ - - - - - + diff --git a/build/classes/.gitignore b/build/classes/.gitignore deleted file mode 100644 index 4e7e508..0000000 --- a/build/classes/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/controller/ diff --git a/build/classes/controller/WebServelet.class b/build/classes/controller/WebServelet.class new file mode 100644 index 0000000000000000000000000000000000000000..ae094ef720744db9c7b5647608547f694ffc3192 GIT binary patch literal 280 zcmZusF>b;@5S%qOCJqT!3Y0b-q==hzL1`jUSx|sTeRfuG=;D(u2meZilp+t{QHVW6 zK|wRKv#Z^i-5>t`0lXql5fS>eZM?I_uq!^fnz7rmVV@!<$RVu{fhFO8R)c7+R@n@QX=^U;)<+>F~Q1uj8wBXK`5kV$0M2VP#;Fp~v=XCj?V z7p4TxaAZN?if*l%8k|u5aKj_0pHFAa+dKDG%-r3?O2!m4%x@(VnT13yZJn!1S0R2Jggf7emsXk-biQJ5GK|aj@9rUKQ$GBJIev0gNE8$RpSt=MefA3)L^Pi zY=i}5;R%$OEm9+Ct^`+ptmhYP_4&o)_j#$PimvLOz4A9jMRY}X@0CB+-MVMlP^`EO z7p=hFN9b5OMCX|5G_(>PI}D%G@H>rw%cv{i{i08be$jm)FNwKU_wj1Ts|PF|^}1hI zb}?k1Nrd_e>HuA1>i&1Xnal5#|FeS_o>pSL==ZZ%=?h}tsPEUCZ z6zfE<)0O@5LQxZ4^X`?W7|<@2_90u~gw>+Q9CWZjDjU> zI$q*Wz#Li-Ct?Y$Smw)5q77@rY!m+m-{u2c!b5c8Ep+1@zR-R2-~;sHBR;=R=9r+UtQ;srI_niv1AAF1? H9Ju)}8a8O! literal 0 HcmV?d00001 diff --git a/build/classes/testing/TestFlamesCheckService.class b/build/classes/testing/TestFlamesCheckService.class new file mode 100644 index 0000000000000000000000000000000000000000..45bcb27bb9635599837c2e7d84a5848a38889338 GIT binary patch literal 1257 zcmaJ=+fEZv6kVq+%uolY1IqpCg>sQ1q9`ERR?yTbMoTdIV3-aE7?{prJ2miTG$ckp z#Agz3(Zmn%qtrDm0kvwR0`L?@}Smt-pF$=Pk z-jvpMP8OfpmQ)ZCh;5nA%!FeSbuYgqEngtKZj}VOjZzhss69C=P(Nq8wm(mFe0W75 zlJ?eQ6k(jupg>j7DA4)u0#Rr<(EzsBP=|VfX2W*nQn`?q#bq<^NCDmOEYn#ri*~R+ zOh)`oo80=1|0^TE)&Q|+yK7bUS?Ozewk2Ycs>?Cr%xq($-AW!n$R5`CALVPpN>C9=>GiX68S5(7%2&Wm>bJfN#Ym3M1SjYH{ z-frlf*_b)svp@0<&7)%<(7pc&{rY)Bk7r|rn*4~Nk7Z-BCO>ZI6WN&aXFez@1dBcl zB7O2G6#7(aKHyuVG?@5KO##JN9H&sNoBZe;S_EPKsMNUxW zC5pU4iPwm~gLd3S2bR!@`$Vpy2U|p!(Z|~TtUiE!4B|CsIIwG~YQv#jVZ6dD=E$U; usOyYE?D_)pxIq^C#NI@bcBgo<4WS<_7f~P-r1|6YD3}ghUf^~Ji$4K$=@FX% literal 0 HcmV?d00001 diff --git a/src/controller/WebServelet.java b/src/controller/WebServelet.java new file mode 100644 index 0000000..0a04874 --- /dev/null +++ b/src/controller/WebServelet.java @@ -0,0 +1,5 @@ +package controller; + +public class WebServelet { + +} diff --git a/src/service/FlamesCheckService.java b/src/service/FlamesCheckService.java index a8c006a..a0c30e4 100644 --- a/src/service/FlamesCheckService.java +++ b/src/service/FlamesCheckService.java @@ -1,9 +1,88 @@ package service; // Create a class called FlamesCheckService -// FlamesCheckService has a method findFlames to find the flames between two names -// char findFlames(String name1, String name2) takes two strings as arguments -// Your task is to calculate the flames value and return the corresponding character as output -// You must return only the following values ['f','l','a','m','e','s'] -// change the return value at the end of the method corresponding to your return value + +import service.FlamesCheckService; + +// Create a class called FlamesCheckService +public class FlamesCheckService { + public char findFlames(String name1, String name2) { + StringBuffer str1 = new StringBuffer(name1); + StringBuffer str2 = new StringBuffer(name2); + int len1 = str1.length(); + int len2 = str2.length(); + P: for (int i = 0; i < len1; i++)// label + { + char a = str1.charAt(i); + + for (int j = 0; j < len2; j++) { + char b = str2.charAt(j); + if (a == b) { + + str1.deleteCharAt(i); + str2.deleteCharAt(j); + len1 = str1.length(); + len2 = str2.length(); + i = 0; + j = 0; + + } + } + + } + + int len = len1 + len2; + StringBuffer str3 = new StringBuffer("flames"); + String str4 = new String(); + + P: for (int i = 0; i < 5; i++) { + int c = -1, d = 0, p = 0; + + for (int j = 1; j <= len; j++) { + c++; + d++; + + if (c > str3.length() - 1) { + char e = str3.charAt(p); + if (d == len) { + str3.deleteCharAt(p); + + str4 = str3.substring(p, str3.length()); + + str3.delete(p, str3.length()); + + str3.insert(0, str4); + + break; + } else { + p++; + if (p == str3.length()) { + p = 0; + } + } + } else { + char e = str3.charAt(c); + if (d == len) { + str3.deleteCharAt(c); + + str4 = str3.substring(c, str3.length()); + + str3.delete(c, str3.length()); + + str3.insert(0, str4); + + break; + } + + } + + } + } + + char result = str3.charAt(0); + return result; + + } + +} \ No newline at end of file diff --git a/src/testing/TestFlamesCheckService.java b/src/testing/TestFlamesCheckService.java index f3b45fe..12ad4cb 100644 --- a/src/testing/TestFlamesCheckService.java +++ b/src/testing/TestFlamesCheckService.java @@ -8,30 +8,30 @@ public class TestFlamesCheckService { FlamesCheckService fcs = new FlamesCheckService(); @Test -// public void testFindFlamesMethod() { -// String name1 = "Alex"; -// String name2 = "Joylin"; -// char temp = 'a'; -// assertEquals(temp,fcs.findFlames(name1, name2)); -// name1 = "Steffe"; -// name2 = "Bobby"; -// temp = 'm'; -// assertEquals(temp,fcs.findFlames(name1, name2)); -// name1 = "John"; -// name2 = "Jully"; -// temp = 'e'; -// assertEquals(temp,fcs.findFlames(name1, name2)); -// name1 = "George"; -// name2 = "Neythiri"; -// temp = 'l'; -// assertEquals(temp,fcs.findFlames(name1, name2)); -// try { -// fcs.findFlames(null, null); -// fcs.findFlames("AAA", null); -// fcs.findFlames(null, "BBB"); -// } -// catch(Exception e) { -// e.printStackTrace(); -// } -// } + public void testFindFlamesMethod() { + String name1 = "Alex"; + String name2 = "Joylin"; + char temp = 'a'; + assertEquals(temp,fcs.findFlames(name1, name2)); + name1 = "Steffe"; + name2 = "Bobby"; + temp = 'm'; + assertEquals(temp,fcs.findFlames(name1, name2)); + name1 = "John"; + name2 = "Jully"; + temp = 'e'; + assertEquals(temp,fcs.findFlames(name1, name2)); + name1 = "George"; + name2 = "Neythiri"; + temp = 'l'; + assertEquals(temp,fcs.findFlames(name1, name2)); + try { + fcs.findFlames(null, null); + fcs.findFlames("AAA", null); + fcs.findFlames(null, "BBB"); + } + catch(Exception e) { + e.printStackTrace(); + } + } }