...

View Full Version : How can I do this?



zexbar
12-09-2009, 01: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) + " ");
}
}
}

tomws
12-09-2009, 02:22 AM
That's Java. You've posted in the Javascript forum. Yes, they're different languages. You should PM a mod to request a move to the correct forum where you can get appropriate assistance.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum