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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:03:06+00:00 2026-05-16T07:03:06+00:00

Imagine I have a game with a base Entity class, with an init method

  • 0

Imagine I have a game with a base Entity class, with an init method that takes no arguments. Now I have a Wizard class, but I want to pass in 2 parameters, say speed and strength. In AS3 (and I believe Java and C#) I will not be allowed to do this – it is an “incompatible override” because the method signatures won’t match. Now I could just make an “initWizard” method instead, but then I have the problem of the init method of each class potentially having different names.

I need solutions that work in AS3, Java or C#.

  • 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-05-16T07:03:07+00:00Added an answer on May 16, 2026 at 7:03 am

    Not sure I understood your question correctly. But the following compiles in Java:

    public class A {
        public void init(int a) {}
    }
    
    public class B extends A {
    
        public void init( int a, int b )
        {
            super.init( a );
        }
    }
    

    Though I agree that B#init(int,int) is not an override of A#init(int), and B#init(int) can still be called. You can not really hide the existence of B#init(int), at best, you could override it in B and let it throw an exception if it is called.

    Is it however so a big problem? The method signature capture only part of the contract of how a class must be used. If you want to shield your code a bit more, you could use a factory method to create instances of A or B and make init protected.

    public class A {
        protected void init(int a) {}
    
        static public A create( int a)
        {
            A o = new A();
            o.init( a );
            return o;
        }
    }
    
    public class B extends A {
    
        protected void init( int a, int b )
        {
            super.init( a );
        }
    
        static public B create( int a, int b)
        {
            B o = new B();
            o.init( a, b );
            return o;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 487k
  • Answers 487k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can make use of MySQL show tables as: SHOW… May 16, 2026 at 8:23 am
  • Editorial Team
    Editorial Team added an answer You can calculate the frame of the UITabBarItem on your… May 16, 2026 at 8:23 am
  • Editorial Team
    Editorial Team added an answer GridView current page May 16, 2026 at 8:23 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Related Questions

No related questions found

Top Members

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.