zexbar
12-09-2009, 12:05 AM
How can I add multiple classes to this or change it to include the following? One that contains the accessor and mutator
methods, a readInput() method and a writeOutput() method.
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
public class PowerBall
{
public static void main(String[] args)
{
ArrayList<Integer> numbers = new ArrayList<Integer>();
for(int i=0; i<59; i++)
{
numbers.add(i + 1);
}
ArrayList<Integer> powerball = new ArrayList<Integer>();
for(int i=0; i<39; i++)
{
powerball.add(i+1);
}
Collections.shuffle(numbers);
Collections.shuffle(powerball);
List <Integer> sorted = numbers.subList(0,5);
Collections.sort(sorted);
System.out.println("");
System.out.print("The powerball numbers are: ");
for (int j=0; j<5; j++)
{
System.out.print(sorted.get(j) + " ");
}
System.out.print(" and the powerball is: ");
for (int k=0; k<1; k++)
{
System.out.print(powerball.get(k) + " ");
}
}
}
methods, a readInput() method and a writeOutput() method.
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
public class PowerBall
{
public static void main(String[] args)
{
ArrayList<Integer> numbers = new ArrayList<Integer>();
for(int i=0; i<59; i++)
{
numbers.add(i + 1);
}
ArrayList<Integer> powerball = new ArrayList<Integer>();
for(int i=0; i<39; i++)
{
powerball.add(i+1);
}
Collections.shuffle(numbers);
Collections.shuffle(powerball);
List <Integer> sorted = numbers.subList(0,5);
Collections.sort(sorted);
System.out.println("");
System.out.print("The powerball numbers are: ");
for (int j=0; j<5; j++)
{
System.out.print(sorted.get(j) + " ");
}
System.out.print(" and the powerball is: ");
for (int k=0; k<1; k++)
{
System.out.print(powerball.get(k) + " ");
}
}
}