aspose file tools*
The moose likes Beginning Java and the fly likes purse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "purse" Watch "purse" New topic
Author

purse

kofi ofei
Ranch Hand

Joined: May 22, 2005
Posts: 39
when i check the programme for errors below none appear. but when i compile the programme it says i should recompile with xlint and when i run the programme nothing happens


import java.util.ArrayList;
import java.lang.String;
/** A purse holds a collection of coins.
*/
public class Purse
{
/** Constructs an empty purse.
*/
public Purse()
{
coins = new ArrayList();

}

/** Adds a coin to the purse.
@param aCoin the coin to add
*/
public void add(Coin aCoin)
{
//aCoin = new Coin(0.1);
coins.add(aCoin);
}

/**
Get the total value of the coins in the purse.
@return the sum of all coin values
*/
public double getTotal()
{
double total = 0;
for (int i = 0; i < coins.size(); i++)
{
Coin aCoin = (Coin)coins.get(i);
total = total + aCoin.getValue();
}
return total;
}
/** Counts the number of coins in the purse.
@return the number of coins
*/
public int count()
{
return coins.size();
}
/** Test whether the purse has a coin that matches a given coin.
@param aCoin the coin to match
@return true if there is a coin equal to aCoin
*/
public boolean find(Coin aCoin)
{
for(int i = 0; i < coins.size(); i++)
{
Coin c = (Coin)coins.get(i);
if (c.equals(aCoin)) return true; //found a match
}
return false; // no match in the entire array list
}
/** Counts the number of coins in the purse that match a given coin.
@param aCoin the coin to match
@return the number of coins equal to aCoin
*/
public int count(Coin aCoin)
{
int matches = 0;
for (int i = 0; i < coins.size(); i++)
{
Coin c = (Coin)coins.get(i);
if (c.equals(aCoin)) matches++; // found a match
}
return matches;
}

/** Find the coin with the largest value.
(Precondition: The purse is not empty)
@return a coin with maximum value in this purse
*/
public Coin getMaximum(/*coins aCoin*/)
{
Coin max = (Coin)coins.get(0);
for (int i= 1; i < coins.size(); i++)
{
Coin c = (Coin)coins.get(i);
if
(c.getValue()> max.getValue());
max = c;
}
return max;
}

private ArrayList coins;
}
//private Coin a;

/** public class Coin
{

public void Coin(double valuec)
{
value =valuec;
//kind = type;

}
public double getValue()
{
return value;
}
private double value;
//private String kind;
}
}*/
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Ditto move to JIG (Beginner)

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: purse