Extending this question, I have accepted an answer which says use lookup table or hashmap for this case as it would be a better construct to handle multiple conditions.
Current construct.
Class to store messages.
public class ProgressMessages
{
public static String msg1="Welcome here .....";
.
.
.
//around 100 more similar static variables.
}
Condition and Display the proper message from the above class.
int x=calculatedVal1(m,n);
int y=calculatedVal2(o,q);
SimpleDateFormat formater=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date d=new Date();
String s=formater.format(d);
try {
long d1 = formater.parse("2013-01-10 13:53:01").getTime();
long d2=formater.parse(s).getTime();
totaldays=Math.abs((d1-d2)/(1000*60*60*24));
} catch (ParseException e) {
e.printStackTrace();
}
if(totaldays<7&&x<20)
{
System.out.println("my message...1"+ProgressMessages.msg1);
}
else if(totaldays<7&&x>10&&y<20)
{
System.out.println("my message...2"+ProgressMessages.msg2);
}
....
//obvioulsy 100 more else-if's to display 100 messages.
I actually would like to know how would a look-up table help in this case?
How should it be implemented in java Hashmap/Hashtable etc, What would be advantageous how?
----Edit---
I am going by @assylias anwer as it is more clean to apply . But If I use Enums then I have got a fix.
To describe the big picture...
i.e. List of messages is like...
1) "Welcome," + nameOfUser+"your success rate is"+ succssRate +"%"+ earlier it was +earlier +"%".
2) "Oh yes.."+ succssRate +"%"+ improved from +earlier +"%".
3.) "Now you should focus on "+exerCiseName.
How could I do this using Enumeration as it has fixed String data. Could I make different constructors? How any example with the edit code to assylas answer?