Extending this question , I accepted the answer, which says that use a lookup table or hashmap for this case, since it would be better to handle several conditions .
Current design.
Class for storing messages.
public class ProgressMessages
{
public static String msg1="Welcome here .....";
.
.
.
}
Condition and display the correct 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);
}
....
I really would like to know how a lookup table will help in this case?
How it should be implemented in java hashmap / hashtable etc. What would be beneficial?
---- Editing ---
I am going to use @assylias anwer as it is cleaner to use. But if I use Enums, then I have a fix.
To describe the big picture ...
. ...
1) " " + nameOfUser + " " + succssRate + "%" + + + +%.
2) " ..." + succssRate + "%" + + + "%" .
3.) " " + exerCiseName ".
Enumeration, String. ? assylas ?