I'm a freshman student in my first computer science class, and I've hit one of many walls in Java development. For a little background, we're working with BlueJ.

Our assignment is to implement an ArrayList into a class that calls upon another class "Circle" to create and modify a large amount of circles all at once.

My difficulty is starting out with implementing ArrayList into the assignment. I've worked with NumberRange, but I'm not exactly sure how to bring in ArrayList and then store objects into the list. I'm not asking for a complete solution, just a starting point to work from. Thanks.

Here's the shoddy code I have so far:

public class SuperCircleDrawer {

private Circle circles;
private ArrayList<Circle> storage;    

    public SuperCircleDrawer()
        ArrayList storage = new ArrayList<Circle>();
    public void addCircle()
        new Circle;
    public void drawCircles()
8 Years
Discussion Span
Last Post by stultuske

Ok, some hints.
1) In your constructor, don't re-declare "storage", just initialize it. You have already declared it at the class level.
2) In your addCircle method, you want to add that new Circle object to your storage list, so look at the methods on ArrayList for adding things.
3) In drawCircles, you need to draw each Circle that you put in the list. Look at your notes on how to iterate the list. For each Circle in the iteration you need to call the methods to draw it.


Also you don't need this in your class:

private Circle circles;

In your class you define the ArrayList of circles, so you don't need that circle object. Everything will be put in that list and you will have methods that add and read or print from that list
You can have a method that adds a Circle object to that list. Maybe the method will have a Circle as a parameter and you can add that to the list.

Also pay attention on how you name your variables: private Circle circles; You define a ONE Circle object and the variable name is plural: cirlces

cirlces would be a good name for your ArrayList if you haven't named it storage, which is also a good name

And to close once you have finished with this class you will instantiate it once in your main method and start calling the add method as many times as you like in order to put circles in it


HI friends

I am Joseph from London. I am trying to find the answer of your question so can you send some detail of the above question.
Times might be tough, but slashing your car insurance is easy, so....
*url removed*Auto Insurance in California*/url removed*]

so ... Joseph from London, who's advertising auto insurances in California ...

you might want to go trough the next steps to find the answers:
1. make an analysis of your problem
2. try to code it yourself
3. if you get stuck somewhere, come back and:
-> a. start your own thread
-> b. ask specific questions
-> c. show us the relevant code
-> d. show the error messages you are getting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.