Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 28th, 2005, 07:59 AM
handy handy is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 8 handy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 26 m 15 sec
Reputation Power: 0
ArrayList and Iterator problems!! Lotto Machine

I am trying to write the ticket class for a lotto ticket machine. I have created a Number class but I am having trouble with the Ticket class, my code is below if anyone can help!!!
import java.util.ArrayList;
import java.util.Iterator;

/**
* Class Ticket.
* Builds a Lucky Dip Lotto Ticket.
* Creates an arrayList of Lucky Dip numbers then displays the ticket and numbers to the screen.
*
* @author #############
* @version ############
*
* Note : The following is only a suggested set of fields, constructors and methods,
* candidates may design their own class if they wish.
*
*/
public class Ticket
{
private int numberOfLines;
private ArrayList lotoLines;

// Constructor : Creates an arrayList of Lucky Dip numbers, takes one argument to load the numberOfLines field.

/**
* Creates an arrayList of Lucky Dip numbers,
* takes one argument to load the numberOfLines field.
*/
public Ticket()
{
lotoLines = new ArrayList();
numberOfLines = 1;
}

// Method : Display the ticket details and the list of Lucky Dip numbers to the screen.

/**
* Show the ticket details and list the list of Lucky Dip numbers to the screen.
*/
public void showNumbers()
{
Iterator it = lotoLines.iterator();
while(it.hasNext()){
Numbers lotoLines = (Numbers) it.next();
System.out.println(lotoLines.toString());
}
}




}

Last edited by handy : March 28th, 2005 at 08:16 AM. Reason: updated code

Reply With Quote
  #2  
Old March 29th, 2005, 08:54 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
In the future, try wrapping your code in [code][/code] tags when posting the forum.

Can you explain further?
What happens when your Ticket class is run?
"What do you expect it to do" vs "What does it do"

This will save us from having to compile the code and create a test class

Reply With Quote
  #3  
Old March 29th, 2005, 09:15 AM
handy handy is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 8 handy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 26 m 15 sec
Reputation Power: 0
Reply to message - Lotto

Hi,
I want to have as many randomly generated Lucky Dips as required
on the same ticket.
I have constructed the numbers class which generates the random numbers. I now need
to link the Ticket class to the numbers class to store the Lucky Dip number sets in a flexible-sized collection(array list)
Display the ticket and the Lucky Dip numbers to the screen in the correct format,
this will Allow an output for a ticket with five lucky dips and an output for a ticket
with three lucky dips.
Thank you in advance for your help

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > ArrayList and Iterator problems!! Lotto Machine


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT