Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8917927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:37:05+00:00 2026-06-15T05:37:05+00:00

I will start by explaining the scenario. I have to create a Vector to

  • 0

I will start by explaining the scenario.
I have to create a Vector to hold a list of Circles.
Then I create a circle object, and add it to the Vector.
Finally I have to print the state of each circle in the list (the state isn’t important to define, just it’s colour and position etc).

Basically my problem is, how do I hold the circles so that I can then pass in the name of one of them and it will print the correct circle’s state. It may be clearer to show you my code.

I have 3 classes, that main one called Lab83Test, the Vector one, called CircleList, and the Circle one, called Circle. (The formatting has gone weird and I can’t fix it, so apologies!)

Lab83Test:

public class Lab83Test {

    public static void main(String[] args) {
        makeNewCircle();
    }
    public static void makeNewCircle() {
        CircleList newList = new CircleList();
        Circle newCircle = new Circle();
        newList.addCircle(newCircle);
        newCircle.makeVisible();
        newList.printDetails();
    }
}

CircleList:

import java.util.Vector;

public class CircleList {
    private Vector circleVector;

    public CircleList() {
        circleVector = new Vector();
    }
    public void addCircle(Circle circleName) {
            circleVector.add(circleName);
            printDetails();
    }
    public void addCircleToPlace(Circle circleName, int pos) {
        circleVector.add(pos, circleName);
        printDetails();
    }
    public void removeCircleFromPos(int pos) {
        circleVector.remove(pos);
        printDetails();
    }
    public void removeAllCircles(int pos) {
        circleVector.clear();
        printDetails();
    }
    public void printDetails() {

    }
}

The circle class isn’t too important, and it has a lot of methods for moving the circle and stuff. The main thing is that it has to return its state.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:37:07+00:00Added an answer on June 15, 2026 at 5:37 am

    If you just want to iterate over all Circel in your list and print their name, you can do it this way:

    public void printDetails() {
      for (Circle c: circleVector) {
        System.out.println(String.format("%s: center=(%.1f/%.1f) radius=%.1f", c.getName(), c.getCenterX(), c.getCenterY(), c.getRadius()));
      }
    }
    

    I don’t know how your Circle class looks so I just assumed some method names.

    If you want to find a specific circle by name:

    for (Circle c: circleVector) {
      if (c.getName().equals(nameToFind)) return c;
    }
    

    Or you could use a Map<String, Circle> instead of your vector and just do return circleMap.get(name);. Your addCircle() would then look like this:

    public void addCircle(Circle circle) {
      circleMap.add(circle.getName(), circle);
      printDetails();
    }
    

    Edit1: regarding your comment: Your vector does not have a defined type. Change this:

    ...
    public class CircleList {
      private Vector<Circle> circleVector;
    
      public CircleList() {
        circleVector = new Vector<Circle>();
      }
      ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I will start by explaining my scenario in code: public class A { }
I have an asp.net page that calls a dll that will start a long
We have an ASP.Net MVC project that will start with a single web server
I have a Screen name DownloaderScreen when the screen start it will start download
Let me start by explaining my scenario: I am developing a quiz engine in
Let me start with explaining what I mean with magic. I will use two
I have an app which will start sending location data to a remote server,
I have an app which will start sending location data to a remote server,
We have legacy applications which soon they will start to use common jsp pages.
Before I start explaining the code I will first give my use case so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.