?
Solved

Java Application that applies conditional logic to a set of tasks

Posted on 2004-03-25
11
Medium Priority
?
197 Views
Last Modified: 2010-03-31
Hi all

I am looking for some people who use or built a java application that applies conditional logic to a set of tasks.  For example, when a locomotive comes into one of our service shops a worker is given a set of static tasks.  What we would like it to be is conditional based, ie.  If user selects inputs 1 for task A, then display task C, else display task B.... right now it lists ALL of the tasks.

I am looking at the technical challenges, what worked and did not work

Thanks - V
0
Comment
Question by:pollacsekv
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
11 Comments
 
LVL 3

Expert Comment

by:fave_17
ID: 10684986
you can use if-else statements, or switch -case statement
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 10685031
Explaining what fave_17 wrote in his first comment a little more, it could be like:

if ( input == 1 )
  -> taskA () ;
else if ( input == 2 )
  -> taskB () ;
else if ( input == 3 )
  -> taskC () ;

or:

switch ( input )
{
  case 1: -> taskA () ;
    break ;

  case 2: -> taskB () ;
    break ;

  case 3: -> taskC () ;
    break ;

  default: System.out.println ( "Invalid input" ) ;

}

Note that the switch-case will not work for String-arguments.
0
 
LVL 15

Expert Comment

by:Javatm
ID: 10685056
There are many ways to do that you can use :

1.) If - Else :

if (YourTask) {
}
else {
}

2.) Switch Case :

switch () {

case A1:
Do your thing . . .
break;

case B1:
Do your thing . . .
break;

default:
Do your thing . . .
}

3.) Try / Catch :

try {
Do your thing . . .
}
catch(Exception e) {
Catch exception . . .
}

Hope that helps . . .
Javatm
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 30

Expert Comment

by:Mayank S
ID: 10685573
Javatm,

>> 3.) Try / Catch :

Why should a try/ catch fit for conditional purposes? You can write anything in a try/ catch block - need not be a conditional statement block. And in the first two cases (if else, switch-case) too, you can have try/ catch blocks. I don't think that try/ catch blocks fit in as a 'different' or an 'isolated' third approach.
0
 
LVL 15

Expert Comment

by:Javatm
ID: 10692225
> Why should a try/ catch fit for conditional purposes?

It is a good approach for programming purposes making a conditional statements will be better handle if you provided
more specific handle to a certain problem.

like :

try {

if () {
}
else {}
}
catch(Exeption) {}

> I don't think that try/ catch blocks fit in as a 'different' or an 'isolated' third approach.

Well you can be correct but you need to actually look on the real purpose why we use try/catch it
is also like if / else statements but with better purposes in Java.

Hope that helps . . .
Javatm
0
 
LVL 15

Accepted Solution

by:
Javatm earned 1000 total points
ID: 10692264
Anyway congrats as I see you've already reached the Master Level, good luck :)
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 10694526
Thanks, buddy.

>> but with better purposes in Java

Exactly. That's because it can be 'coupled' with anything, be it an if-else, a switch-case or any Java code :-)
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 10731166
Was that the answer ;-) ??
0
 
LVL 15

Expert Comment

by:Javatm
ID: 10737087
I dont know why I received the points but thanks anyway . . .

http://www.freewebs.com/cube-j

Always glad to help . . .
Friend : Javatm
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 10738315
Points are ok, but if the accepted answer had been your first commet, it was better. Some people don't realize that they should select the appropriate answer - they just select any comment from the person whom they want to give the points and they think that its done.

But think about non-members. While browsing, if they open some pages on this site and if the question meets what they are searching for, they will quickly click on the "See Solution" link which takes to the Accepted Answer. Now if that is not the actual answer, then the person has to go through the trouble of going through all comments to see which could've been the right one. That gives a slightly bad impression of EE.

In fact, even when members are searching for answers in some old questions, they tend to click the "See Solution" link and it'd be better if it takes them to the actual answer only.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month10 days, 16 hours left to enroll

770 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