Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: what is wrong with my code

  1. #1
    Junior Member
    Join Date
    Dec 2012
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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("****************************** ");
    }
    }


  2. #2
    Super Moderator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,225
    Thanks
    176
    Thanked 817 Times in 760 Posts
    Blog Entries
    5

    Default 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.

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,067
    Thanks
    47
    Thanked 2,146 Times in 2,119 Posts

    Default 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.
    If you don't understand my answer, don't ignore it, ask a question.

  4. #4
    Junior Member
    Join Date
    Dec 2012
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: what is wrong with my code

    Quote Originally Posted by Norm View Post
    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

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,067
    Thanks
    47
    Thanked 2,146 Times in 2,119 Posts

    Default 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.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. what is wrong with my code
    By BLUEJ in forum What's Wrong With My Code?
    Replies: 4
    Last Post: January 10th, 2013, 06:52 PM
  2. What is wrong with this code?
    By dannyboi in forum What's Wrong With My Code?
    Replies: 7
    Last Post: July 24th, 2012, 12:31 AM
  3. What is wrong with my code?
    By dannyboi in forum What's Wrong With My Code?
    Replies: 5
    Last Post: July 23rd, 2012, 02:40 PM
  4. What is wrong with my code?
    By unleashed-my-freedom in forum What's Wrong With My Code?
    Replies: 5
    Last Post: July 3rd, 2012, 12:41 AM
  5. What's wrong with my code?
    By mjballa in forum What's Wrong With My Code?
    Replies: 8
    Last Post: November 19th, 2011, 02:57 PM