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 8963271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:19:18+00:00 2026-06-15T16:19:18+00:00

Hey im making a planeManagerApp. I have a TreeMap containing Airline , HashMap(String,Plane); I

  • 0

Hey im making a planeManagerApp. I have a TreeMap containing Airline , HashMap(String,Plane);

I want the airline to print out planes belonging to it. So for RyanAir i want 3 planes to print out for them and for AerLingus i want 3 planes to print out for them. But when i run i get the Airline added last with all planes added.

Here is my code:

import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;


public class MainApp
{
    public static void main(String[] args)
    {
        //PlaneStore map = new PlaneStore();

        Airline a1 = new Airline("Aer Lingus");

        Plane p1 = new Plane("A01", 150.5, 10.5, 500, Plane.AIRPLANETYPE.AIRBUS);
        Plane p2 = new Plane("B01", 50.3, 1.5, 91, Plane.AIRPLANETYPE.CORPORATE);
        Plane p3 = new Plane("C01", 12.2, -3.1, 56, Plane.AIRPLANETYPE.AIRBUS);

        Airline a2 = new Airline("Brian Air");

        Plane p4 = new Plane("D01", 10.5, 1.5, 430, Plane.AIRPLANETYPE.PRIVATE);
        Plane p5 = new Plane("E01", 0.3, 2.1, 101, Plane.AIRPLANETYPE.CORPORATE);
        Plane p6 = new Plane("F01", 2.2, -3, 291, Plane.AIRPLANETYPE.AIRBUS);

        HashMap<String, Plane> airlineMap = new HashMap<String, Plane>();

        airlineMap.put(p1.getFlightNumber(), p1);
        airlineMap.put(p2.getFlightNumber(), p2);
        airlineMap.put(p3.getFlightNumber(), p3);

        airlineMap.put(p4.getFlightNumber(), p4);
        airlineMap.put(p5.getFlightNumber(), p5);
        airlineMap.put(p6.getFlightNumber(), p6);

        TreeMap<Airline, HashMap<String, Plane>> map = new TreeMap<Airline, HashMap<String, Plane>>();
        map.put(a1, airlineMap);
        map.put(a2, airlineMap);

        System.out.println("\n-------- PRINT KEY DETAILS --------");
        for(Map.Entry theEntry : map.entrySet())
            System.out.println(theEntry.getKey());

        for(Map.Entry theEntry : map.entrySet())
        {   
            HashMap<String, Plane> map2= (HashMap<String, Plane>)theEntry.getValue();

            System.out.println("\n-------- PRINT CLIENT DETAILS --------");
            for(Map.Entry theNextEntry : map2.entrySet())
                System.out.println(theNextEntry.getValue());    
        }

        //Plane p4 = new Plane("D01", 300.9, 45, 402, Plane.AIRPLANETYPE.PRIVATE);
        //Plane p5 = new Plane("E01", 455, 23, 100, Plane.AIRPLANETYPE.AIRBUS);

        //Airline.airlineMap.add("Aer Lingus", p1);



       // map.put(Airline.getAirlineName(), p1);


    }
}
  • 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-15T16:19:19+00:00Added an answer on June 15, 2026 at 4:19 pm

    The planes are never associated with a specific airline. You create 6 planes, give them flight numbers. Associate the flight numbers with the plane and then associate both airlines with the entire airlineMap hashmap.

    map.put(a1, airlineMap);
    map.put(a2, airlineMap);
    

    This line is the only line that associates airplanes with airlines.

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

Sidebar

Related Questions

hey guys having this really simple problem but cant seem to figure out have
Hey guys I am making a 2D game and I have generating a random
Hey guys I'm making a chat program and I have a parent MessagePacket class
Hey, making a media player and need to know something. I have a menu
Hey guys I have a problem with an app I'm making. The thing is
Hey guys, I'm making a quiz with a limit, I want to keep track
Hey out there in Stackland. I'm making a very javascript-heavy site, and at a
Hey so i have a sprite class, and i am making it turn 360
Hey Frens I am making one project in asp.net C#, in which i have
hey guys, I have no luck making a simple background image animation working without

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.