I am trying to create a tree map within a TreeMap.
Any help would be great.
goes a bit like this:
[code=java]
public class ChessImpl implements CHESS
{
private Map<String, Integer> name;
private int membernumber;
private Map<String, Map<Integer, Holding>> stock;
private Map<Integer, Holding> intSearch;
private Holding holder;
public ChessImpl()
{
name = new TreeMap<String, Integer>();
membernumber = 1;
stock = new TreeMap<String, Map<Integer, Holding>>();
}
[/code]
With the stock map do I need to create another map before i insert it?
Main problem is when i use the put method it wont accept it?
[code=java]
public void issue(String stockCl, String client, int nshares)
{
if(name.contain sKey(client) && (nshares > 100))
{
Holding holder = new Holding(stockCl , client, nshares);
int memNum = name.get(client );
stock.put(stock Cl, (memNum, holder)) //THIS IS WHERE IM HAVING THE MAJOR PROBLEM
}
else
{
System.out.prin tln("Client name has not been created or the amount of shares is less than 100");
}
[/code]
I keep getting a error message. this is the holding class just for refrence.
[code=java]
public class Holding
{
private String stock;
private String client;
private int shares;
public Holding(String stock, String client, int shares)
{
this.stock = stock;
this.client = client;
this.shares = shares;
}
[/code]
Any help would be great.
goes a bit like this:
[code=java]
public class ChessImpl implements CHESS
{
private Map<String, Integer> name;
private int membernumber;
private Map<String, Map<Integer, Holding>> stock;
private Map<Integer, Holding> intSearch;
private Holding holder;
public ChessImpl()
{
name = new TreeMap<String, Integer>();
membernumber = 1;
stock = new TreeMap<String, Map<Integer, Holding>>();
}
[/code]
With the stock map do I need to create another map before i insert it?
Main problem is when i use the put method it wont accept it?
[code=java]
public void issue(String stockCl, String client, int nshares)
{
if(name.contain sKey(client) && (nshares > 100))
{
Holding holder = new Holding(stockCl , client, nshares);
int memNum = name.get(client );
stock.put(stock Cl, (memNum, holder)) //THIS IS WHERE IM HAVING THE MAJOR PROBLEM
}
else
{
System.out.prin tln("Client name has not been created or the amount of shares is less than 100");
}
[/code]
I keep getting a error message. this is the holding class just for refrence.
[code=java]
public class Holding
{
private String stock;
private String client;
private int shares;
public Holding(String stock, String client, int shares)
{
this.stock = stock;
this.client = client;
this.shares = shares;
}
[/code]
Comment