what is wrong with my code
hi,
again there is something wrong with my code it comes it with and error and highlights lottoticket.add(new Numbers());
no suitable method found for add(numbers)
import java.util.ArrayList;
/**
* lucky dip lottery ticket system.
*
* @author (Daniel Prempeh)
* @version 1.1 2013
*/
public class Ticket
{
//array list store instances of number class
private ArrayList<Numbers[]> lottoticket;
private int qty = 6;
public Ticket(int qty)
{
lottoticket = new ArrayList<Numbers[]>();
//needs a loop
for(int i=6; i<qty; i++)
{
lottoticket.add(new Numbers());
}
}
//print out ticket
public void printTicket()
{
//printout header of ticket
System.out.println("****************************** ");
System.out.println("** **");
System.out.println("** Ticket **");
System.out.println("** **");
System.out.println("****************************** ");
//code
//for loop
for(int i=6; i<qty; i++)
{
lottoticket.get(0).print();
}
//printout footer of ticket
System.out.println("** **");
System.out.println("****************************** ");
}
}
Re: what is wrong with my code
Please read the forum rules - in particular the sections regarding meaningful subject titles and wraping your code in the code tags.
Re: what is wrong with my code
Look at the definition of lottoticket. What kind of data does it hold?
Is that the kind of data being used in the add() method?
Hint: an array is not the same as the type of data in the array.
Re: what is wrong with my code
Quote:
Originally Posted by
Norm
Look at the definition of lottoticket. What kind of data does it hold?
Is that the kind of data being used in the add() method?
Hint: an array is not the same as the type of data in the array.
Hi,
now it prints out this line which is what I want
******************************
** **
** Ticket **
** **
******************************
** 4,16,27,30,40,47 **
******************************
but now I want to have a row of unique ascending 6 numbers for example 4, 16, 27, 30, 40, 47, i had them before now they have disapeared
Re: what is wrong with my code
What is wrong with what is printed out now?
What you posted for the output looks like what you say you want.