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

  • SEARCH
  • Home
  • 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 7755409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:33:41+00:00 2026-06-01T12:33:41+00:00

I’m creating an air traffic control system. I have a class called plane that

  • 0

I’m creating an air traffic control system. I have a class called plane that is the one being observed for any changes which is the name changes when a plane is generated at random. The issue is though that the airport needs to access the name to the name to store it into an array list possibly a queue if I can get it working. Anyway this is the code for the airport class:

    /*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package airtrafficcontrolv3;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author
 */
public class Airport
{
        Subject s = new SubjectImpl();

    Plane point = new Plane();
    Queue <String> waiting = new LinkedList<String>();

    public Airport()
    {
        //String name =
        s.getState();
        System.out.println(s);

        while (!waiting.isEmpty())
        {
            System.out.println("Waiting to take off: "+waiting);
            try
            {
                System.out.println("Preparing to taxi: "+waiting.remove());
                Thread.sleep(5000);
            }
            catch (InterruptedException ex)
            {
                Logger.getLogger(Airport.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }

}

I wasn’t sure if I had to have access to the subject that is being observed as in the subject I have a getstate method which is currently what is being pointed to, however it comes out generated in random numbers and letters:

airtrafficcontrolv3.SubjectImpl@5a199939

This is what I have in my subject class:

    package airtrafficcontrolv3;

/*
 * @author S0082708
 */

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

interface Subject
{

    public void addObserver(Observer o);

    public void removeObserver(Observer o);

    public String getState();

    public void setState(String state);
}

/*
 * Creates an observer that will watch for any changes
 */

interface Observer
{
    public void update(Subject o);
}

/*
 * Class implements the observer
 * Observer is what is doing the watching
 * The string is set to blank waiting ready for any updates that will occur
 * Anything in getState is then passed to state
 */
class ObserverImpl implements Observer
{
    private String state = "";

    public void update(Subject o)
    {
        state = o.getState();

        //Need to add text to the label
       // AirTrafficControlv3View.Incoming.add(state);

    }
}

/*
 * Subject is what is being watched
 * The array is then created to store the information ready to add further information
 * Or ready to delete
 * State is set to blank ready for whatever information is being passed
 */

class SubjectImpl implements Subject
{

    private List observers = new ArrayList();
    private String state = "";

    /*
     * Returns whatever is being passed to state
     */

    public String getState()
    {
        //System.out.println(state);
        return state;
    }

    /*
     * Sets the state to current state and then notifies the observer of the changes
     * Made to the state ready to update
     */
    public void setState(String state)
    {
        this.state = state;
        notifyObservers();
    }

    /*
     * Adds the observer along with the name, so several observers can be implemented
     */
    public void addObserver(Observer o)
    {
        observers.add(o);
    }

    /*
     * Removes the observer once it has been used
     */

    public void removeObserver(Observer o)
    {
        observers.remove(o);
    }

    /*
     * The iterator allows the ability to loop through the array
     * While the iterator has a next then it allows the ability to take in more
     * Changes to be observed. It is then updated with the current information
     */

    public void notifyObservers()
    {
        Iterator i = observers.iterator();
        while (i.hasNext())
        {
            Observer o = (Observer) i.next();
            o.update(this);
        }      
    }
}

Can anyone point me in the right direction as of how to get the string from get state which is coming out as KLM fine, but it won’t come out in the airport class.

Any suggestions would be greatly welcomed.

  • 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-01T12:33:42+00:00Added an answer on June 1, 2026 at 12:33 pm

    You need to implement a toString() in the class of the object that is pointed to which you return from getState() the random numbers you get is the default implementation of toString() in the Object class which presents instance identity, not content.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,

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.