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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:17:36+00:00 2026-05-24T23:17:36+00:00

I have a this java application i am working on to get more experience

  • 0

I have a this java application i am working on to get more experience with design patterns and OODesign. The application allows the user to select “equations” from a list. And then the user will be prompted with parameters for the selected equation and will be given a button to press to solve the equations.

I am implementing the equations as a strategy pattern. I am trying to figure out how to get the names of the equations into the list box. I was wondering if there was a way for the Equation classes that implement the EquationInterface to have a variable called equationName. That would allow the programmer to assign the specific equation a name when they are coding up the class for that specific equation. Code is listed below.

Example: When the programmer is designing a new equation to add to the program, they are required to include a name for the strategy created.

If you have any questions, please let me know. I am having a hard time explaining what i am trying to accomplish. And if you have any suggestions on a better design patter to use or way of accomplishing this goal, please let me know.

public class Equation {
    public enum equationList {
        DISTANCETRAVELLEDFALLINGOVERTIME,
        TIMEFOROBJECTFALLDISTANCE
    }

    private EquationInterface solveInterface;

    public Equation(EquationInterface solveInterface) {
        this.solveInterface = solveInterface;
    }

    public void solve() {
        solveInterface.performSolve();
    }

    public JPanel getParameterPanel() {
        return solveInterface.createParameterPanel();
    }
}

public interface EquationInterface {

    public JPanel createParameterPanel();

    public void performSolve();
}

public class DistanceTravelledFallingOverTime implements EquationInterface {

    @Override
    public void performSolve() {
        // TODO Auto-generated method stub
        System.out.println("DistanceTravelledFallingOverTime");
    }

    @Override
    public JPanel createParameterPanel() {
        // TODO Auto-generated method stub
        return null;
    }

}
  • 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-24T23:17:38+00:00Added an answer on May 24, 2026 at 11:17 pm
    public interface EquationInterface {
    
        public JPanel createParameterPanel();
    
        public void performSolve();
    
        public void setEquationName(String equationName);
        public String getEquationName();
    }
    

    I would use getter type method instead of a variable.

    One sample implementation

    public class  SampleEquation implements EquationInterface {
    
        public JPanel createParameterPanel(){return null;}
    
        public void performSolve(){
        //solving an equation
        }
    
        private String equationName = "MyDefaultEquationName";// or = null
    
        public void setEquationName(String equationName){
          this.equationName = equationName;
        }
    
        public String getEquationName(){
          return this.equationName;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In our application, I have seen code written like this: User.java (User entity) public
So I have this nice spiffy MVC-architected application in Java Swing, and now I
I have this application written in java to calculate pageranks. And the application takes
In my Java application I have some copy-constructors like this public MyClass(MyClass src) {
I have an application that passes in java.util.Date. I want to check whether this
I have an application which resides in ROOT. This application has a java class(in
I have a working prototype of a Java application that is using Apache Commons
I have been working on a java application that has a connection to a
I have a decent working web application (Java/Servlet/Jsp) that I would like to improve
I'm working on a live video Java application, and have run into the common

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.