All pastes #364400 Raw Edit

Mine

public java v1 · immutable
#364400 ·published 2007-02-20 03:50 UTC
rendered paste body
import java.util.*;/**   A purse holds a collection of coins.*/public class Purse{       public void Purse()   {    String coinName=" ";    coins.add(coinName);              }        public void add(String coinName)   {             coins.add(coinName);                   }      public String toString()   {         String data="";                    for (String x: coins)           {           	           	data+=x;           	           }                      return data;   }      public String reverse()   {   	String data2="";   	   	for (int i=coins.size(); i>-1; i--)   	{   		 data2=coins.get(i);   		}   		return data2;      	}   	   	   	public void transfer(Purse other)   	{   		for (String x:coins)   		{   			other.add(x);   		}  		   		   		for (String x:coins)   		{   			coins.remove(x);   		}   	}        public boolean sameContents(ArrayList other)    {    	    	    		 boolean same = false;    		 String x=coins.toString();	    		 String y=other.toString();			    	    	for (int i=0; i<coins.size();i++)    	{    	      if (coins.get(i).equals(other.get(i)))    	           {    	           		same = true;    	           }	    	      else     	      	same = false;	    	    	}    	    	return same;    	    }        public boolean sameCoins(ArrayList <String> other)    {    	double sum1=0.0;    	double sum=0.0;    	for (String x:other)    	{    		if (x.equals("nickle"))    		{    			sum+=.05;    		}    		    	 else if (x.equals("dime"))    		{    			 sum+=.1;    		}    		    	 else if (x.equals("nickle"))    		{    			 sum+=.05;    		}    		    		else if (x.equals("quarter"))    		{    			 sum+=.25;    		}    		else if (x.equals("penny"))    		{    		sum+=.01;    		}	    	    		        	    	  	for (String y:coins)    		{    		if (y.equals("nickle"))    		{    			 sum1+=.05;    		}    		    	 else if (y.equals("dime"))    		{    			 sum1+=.1;    		}    		    	 else if (y.equals("nickle"))    		{    			 sum1+=.05;    		}    		    	else if (y.equals("quarter"))    		{    			 sum1+=.25;    		}    	else if (y.equals("penny"))    	{    		sum1+=.01;    	}	    	    	    	    	    		    		    	}        	}    	if (sum1==sum)    		{    			return true;    		}    		else return false;               	  }  private ArrayList<String> coins;}