Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How can I do this?

    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) + " ");
    }
    }
    }

  • #2
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    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.
    Are you a Help Vampire?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •