| | |
Java Code for interesting Java Game
![]() |
Hello everyone!
The other day as I was surfing the net I came accross this Java Game on this web page:
http://www.bosanci.net/ljubav.php
*It is a foreign language and it is a "Crush Calculator" - It asks you to type in a male name in the first string and a female in the second... Then it calculates the final procentage between those 2 persons...
...Ever since, I have been trying to figure out how it works. I dont get how it converts the letters to numbers and a formula or calculations it does to get a final number in the end??
So if someone has ANY ides PLEASE reply.... It would be much appreciated!
The other day as I was surfing the net I came accross this Java Game on this web page:
http://www.bosanci.net/ljubav.php
*It is a foreign language and it is a "Crush Calculator" - It asks you to type in a male name in the first string and a female in the second... Then it calculates the final procentage between those 2 persons...
...Ever since, I have been trying to figure out how it works. I dont get how it converts the letters to numbers and a formula or calculations it does to get a final number in the end??
So if someone has ANY ides PLEASE reply.... It would be much appreciated!
>how it converts the letters to numbers
simply put whole alphabet in array and then read name character by character and check out position of character in array and you getter number (there was also some method to do so but can't remember)
algorithm behind will be something silly for combination of peter+marta I got 15% (2 letters same in the names) and for combination peter+petra it returned it 35% (4 letters same in the names where on repeat twice in first "e") so maybe if you try some arabic or other exotic long names you may get some better score
simply put whole alphabet in array and then read name character by character and check out position of character in array and you getter number (there was also some method to do so but can't remember)
algorithm behind will be something silly for combination of peter+marta I got 15% (2 letters same in the names) and for combination peter+petra it returned it 35% (4 letters same in the names where on repeat twice in first "e") so maybe if you try some arabic or other exotic long names you may get some better score
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
you can simply write a crush calculator by yourself
you either love her/him or not
Java Syntax (Toggle Plain Text)
int calc(string name1, string name2) { //you can also put any silly calculation return 50; }
•
•
Join Date: Jun 2007
Posts: 59
Reputation:
Solved Threads: 3
So this is a method, which calculates the percentage:
Or something like that. You can improve it, and add various calculations. Have fun
Java Syntax (Toggle Plain Text)
for (int i=0; i<mName.length()-1; i++) { for (int j=i+1; j<fName.length()-1;j++) if (mName.charAt[i] == fName.charAt[j]) ok = true; if (ok == true) ++nr; } allChars = fName.length() + mName.length(); percentage = (nr*100)/allChars;
Last edited by Chaster; Jun 15th, 2007 at 1:36 pm.
It is even cheaper then that. Shame I didn't think of it last night. You just need to look at page source to see what is there
. And this is what you get
So he didn't make it, he just took it from other website
. And this is what you get JavaScript Syntax (Toggle Plain Text)
<script LANGUAGE="JavaScript"> <!-- This script and many more are available free online at --> <!-- The JavaScript Source!! http://javascript.internet.com --> <!-- Begin function calc() { first = document.loveform.name1.value.toUpperCase(); firstlength = document.loveform.name1.value.length; second = document.loveform.name2.value.toUpperCase(); secondlength = document.loveform.name2.value.length; var LoveCount=0; for (Count=0; Count < firstlength; Count++) { letter1=first.substring(Count,Count+1); if (letter1=='L') LoveCount+=3; if (letter1=='O') LoveCount+=3; if (letter1=='V') LoveCount+=2; if (letter1=='E') LoveCount+=3; if (letter1=='Y') LoveCount+=3; if (letter1=='O') LoveCount+=1; if (letter1=='U') LoveCount+=3; } for (Count=0; Count < secondlength; Count++) { letter2=second.substring(Count,Count+1); if (letter2=='L') LoveCount+=3; if (letter2=='O') LoveCount+=2; if (letter2=='V') LoveCount+=2; if (letter2=='E') LoveCount+=3; if (letter2=='Y') LoveCount+=3; if (letter2=='O') LoveCount+=1; if (letter2=='U') LoveCount+=3; } amount=0; if (LoveCount> 0) amount= 5-((firstlength+secondlength)/2) if (LoveCount> 2) amount= 10-((firstlength+secondlength)/2) if (LoveCount> 4) amount= 20-((firstlength+secondlength)/2) if (LoveCount> 6) amount= 30-((firstlength+secondlength)/2) if (LoveCount> 8) amount= 40-((firstlength+secondlength)/2) if (LoveCount>10) amount= 50-((firstlength+secondlength)/2) if (LoveCount>12) amount= 60-((firstlength+secondlength)/2) if (LoveCount>14) amount= 70-((firstlength+secondlength)/2) if (LoveCount>16) amount= 80-((firstlength+secondlength)/2) if (LoveCount>18) amount= 90-((firstlength+secondlength)/2) if (LoveCount>20) amount=100-((firstlength+secondlength)/2) if (LoveCount>22) amount=110-((firstlength+secondlength)/2) if (firstlength==0 || secondlength==0) amount= "Err"; if (amount < 0) amount= 0; if (amount >99) amount=99; document.loveform.output.value=amount+"%"; } // End --> </script>
Last edited by peter_budo; Jun 15th, 2007 at 1:44 pm.
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
The Dude you are genius, Iwould not know if you do not tell me so 
and I just provided answer

•
•
•
•
Originally Posted by LSPUWILLC
I have been trying to figure out how it works. I dont get how it converts the letters to numbers and a formula or calculations it does to get a final number in the end??
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
![]() |
Similar Threads
- Executing Shell script from Java code. (Java)
- download jar files using java code (Java)
- I want to know about the java code. Help please!!!! (Java)
- adding an image to a java code (Java)
- Move out java code from jsp (Java)
- Help with Java code (Java)
- Can N E 1 Help!!!! -- Need sample Java code (Java)
- java code newbie (Java)
Other Threads in the Java Forum
- Previous Thread: full screen applet in java
- Next Thread: how to call a method defined in another file?
| Thread Tools | Search this Thread |
911 addball addressbook android api append applet application apps array arrays automation binary bluetooth businessintelligence button card chat class client code collision component crashcourse css csv database eclipse ee error fractal free game gis givemetehcodez graphics gui html ide image integer integration j2me japplet java javaarraylist javadoc javafx javaprojects jni jpanel julia jvm linux list loan machine map method methods migrate mobile netbeans newbie objects oriented output panel phone physics problem program programming project projects radio recursion replaydirector reporting scanner se server service set sms socket software sort sql string swing test textfield threads transfer tree trolltech ubuntu utility windows






