|
The Love Calculator !!!! |
Friday, June 16, 2006 |
import java.util.*;
class Love { private String name1; private String name2;
public void setFirstName( String name1 ){ this.name1 = name1.toUpperCase(); }
public void setSecondName( String name2 ){ this.name2 = name2.toUpperCase(); }
public void setNames( String name1, String name2 ){ this.name1 = name1.toUpperCase(); this.name2 = name2.toUpperCase(); }
private Vector getCount(){ Vector list = new Vector(); String love = "LOVE"; String name1 = this.name1; String name2 = this.name2; for( int i=0; iString temp = name1.charAt(i) + "";
if( list.contains(temp) ){ int indexOfElement = list.indexOf( temp ); int prevCount = Integer.parseInt( list.get(++indexOfElement).toString() ); prevCount++; String newCount = (prevCount) + ""; list.set( indexOfElement, newCount ); continue; }
list.add( temp ); list.add( "1" ); }
for( int i=0; iString temp = name2.charAt(i) + "";
if( list.contains(temp) ){ int indexOfElement = list.indexOf( temp ); int prevCount = Integer.parseInt( list.get(++indexOfElement).toString() ); prevCount++; String newCount = (prevCount) + ""; list.set( indexOfElement, newCount ); continue; }
list.add( temp ); list.add( "1" ); }
for( int i=0; iString temp = love.charAt(i) + "";
if( list.contains(temp) ){ int indexOfElement = list.indexOf( temp ); int prevCount = Integer.parseInt( list.get(++indexOfElement).toString() ); prevCount++; String newCount = (prevCount) + ""; list.set( indexOfElement, newCount ); continue; }
list.add( temp ); list.add( "1" ); }
Vector result = new Vector();
for( int i=1; iresult.add( list.get(i) ); }
//System.out.println( result ); return result; }
public int getLovePer(){ Vector count = getCount(); if( count.size() == 1 ){ String result = count.get(0).toString() + ""; return Integer.parseInt(result); }
if( count.size() == 2 ){ String result = count.get(0).toString() + count.get(1).toString(); return Integer.parseInt(result); }
do{ Vector sub = new Vector(); int size = count.size() / 2; //System.out.println( count.size() / 2 ); for( int i=0; iString newC = ( Integer.parseInt( count.get(i).toString() ) + Integer.parseInt( count.get( count.size() - 1 - i ).toString() ) ) + "";
if( newC.length() == 2 ) { sub.add( (newC.charAt(0) + "") ); sub.add( (newC.charAt(1) + "") ); }else{ sub.add( newC ); } }
if( (size*2) != count.size() ) sub.add( count.get(size) );
count = new Vector(); count = sub; //System.out.println( count ); }while( count.size() != 2 );
String result = count.get(0).toString() + count.get(1).toString(); return Integer.parseInt(result); }
public int getLovePer( String name1, String name2 ){ String temp1 = this.name1; String temp2 = this.name2;
setNames( name1, name2 ); int lPercentage = getLovePer(); setNames( temp1, temp2 );
return lPercentage; }
public String toString(){ String result = "[ Love Percentage Between " + this.name1 + " And " + this.name2 + " is " + getLovePer() + "% ]"; return result; }
public static void main(String[] args) { //System.out.println("Hello World!"); Love love = new Love(); if( args.length == 2 ){ love.setNames( args[0], args[1] ); System.out.println( "\n" + love + "\n" ); System.exit(0); }else{ System.out.println( "\nUse With Proper usage, Find a sample FREINDSHIP Below\n java FriendShip name1 name2 \n" ); } love.setNames( "krishna", "radha" ); System.out.println( "\n" + love + "\n" ); } }
Download API & Java Source Code For Love Calc here....
|
posted by Zaara @ 11:27 AM
|
|
|
|
|