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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:51:14+00:00 2026-06-12T17:51:14+00:00

This code is not mine and i need to add some improvements to it,

  • 0

This code is not mine and i need to add some improvements to it, but i’m stuck in this problem.

I have an abstract class “CallNode” and a lot of subclasses, one of them is “Call”. The “Checker” class is intercepting missed calls, but return them as CallNode. My problem is that i need to get the id of this call, but i can’t access it by CallNode.

Do you have any suggestions to solve this problem?

I let you the code, so that you can better understand the problem:

public abstract class CallNode {
    public abstract CallNode hasMissingCall();
}

public class Call extends CallNode {
    public int id;

    // Simplification of method
    public CallNode hasMissingCall() {  
        if (true)
            return this;
        // ...
    }
}

public class Checker{
    private static CallNode rootExpected;

    CallNode missing = rootExpected.hasMissingCall();

    System.out.println( missing.id ); // THE PROBLEM!!!
}

Thank’s in advance!!!

  • 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-12T17:51:16+00:00Added an answer on June 12, 2026 at 5:51 pm

    Define a template method returning the id in the abstract class:

    public abstract class CallNode {
        public abstract CallNode hasMissingCall();
    
        public abstract int getId();
    }
    

    let subclass implement it:

    public class Call extends CallNode {
        public int id;
    
        // Simplification of method
        public CallNode hasMissingCall() {  
            if (true)
                return this;
            // ...
        }
        public int getId()
        {
             return this.id;
        }
    }
    

    That’s an option. Personally I’ll move the id field upward in the CallNode class, since I think it’s supposed to be unique and shared by all subclasses.

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

Sidebar

Related Questions

This problem is not mine, so I will need some time to provide details.
This code is working on other test environment but not on mine. Do you
Got some code that is not mine and its producing this warning atm: iehtmlwin.cpp(264)
I'm working with some code (not mine I hasten to add, I don't trust
Why does this code not print an exception stack trace? public class Playground {
This code is not pretty, but I want to print out the last generated
This code does not throw an error but the query fails, that is, the
I have some very simple sample code like this: $.ajax({ url: 'demo2.htm', success: function(loadeddata){
I have this piece of HTML code. <div class=tagWrapper> <i style=background-image: url(https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/390945_10150419199065735_543370734_8636909_2105028019_a.jpg);></i> </div> I
Yet another argument with a friend of mine. Consider this code: class User <

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.