Solved

Help required in designing a Java application

Posted on 2012-04-12
5
601 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to implement Singleton Design Pattern in Java.

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now