Solved

Help required in designing a Java application

Posted on 2012-04-12
5
607 Views
Last Modified: 2012-08-13
I am seeking the help for the best Java design that I should use for a particular scenario described below.

1) A button press generates a String Array that contains 'n' strings.

2) I need to check whether this 'Generated Array' contains a pre-defined string(out of 'n' pre-defined strings).

3) If the 'Generated Array' contains any of the pre-defined strings, I need to take an action.

What is the best way of designing this application/ How should I model the classes?

Following is the raw thought I have

1) Main class which handles the Array Generation on Button press
2) A dedicated class for pre-defined strings in which I define 10, 100 , 1000 or more pre-defined strings alone?
3) A dedicated class to handle the actions, if match occurs between 'Generated Array' strings and pre-defined string?

Is this the correct model? Are there any other better design than this?


Best suggestions and guiding is much appreciated
0
Comment
Question by:Sreejith22
5 Comments
 
LVL 41

Expert Comment

by:HonorGod
ID: 37844389
When you say "a button press", that implies a graphical user interface (GUI).
Did you really mean that?

If so, which GUI framework will you be using?  Swing?

How familiar are you with event driven application development?
0
 
LVL 20

Assisted Solution

by:gatorvip
gatorvip earned 117 total points
ID: 37844412
>>A button press generates a String Array that contains 'n' strings.

I don't understand this part - you create random strings? Otherwise this reads like a simple array declaration to me.
i.e., String[] arr = new String[n];

>>2) I need to check whether this 'Generated Array' contains a pre-defined string(out of 'n' pre-defined strings).

How do you populate your array, where are the string values coming from?
0
 
LVL 37

Assisted Solution

by:zzynx
zzynx earned 116 total points
ID: 37844910
>> 1) Main class which handles the Array Generation on Button press
Agree. And that also triggers the action to be taken in case of a match [3)]

>> 2) A dedicated class for pre-defined strings in which I define 10, 100 , 1000 or more pre-defined strings alone?
Agree. And that also contains a method that takes an array of strings as a parameter and returns a boolean telling you if the passed Array contains any of the pre-defined strings.

>> 3) A dedicated class to handle the actions, if match occurs between 'Generated Array' strings and pre-defined string?
Can be a dedicated class. But can also be a method defined in your main class. Depending on how complex the action to be taken is
0
 
LVL 8

Accepted Solution

by:
stmani2005 earned 117 total points
ID: 37896981
Use Abstract class and Interface

Abstract class you define the method and generate Array Using Interfact Reference you get the arrat

Use Swing Button When Action Perform method you would call the Interface and abstract class

Or JSP UseBean you callt the abstract class or Intrface
0
 
LVL 37

Expert Comment

by:zzynx
ID: 37918081
Thanx 4 axxepting
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
The viewer will learn how to implement Singleton Design Pattern in Java.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question