String[] message = new String[5];
public Advisorr(){
message[0] = "Advice: Never say No";
message[1] = "Advice : Don't Betray !";
message[2] = "Advice : Stay calm";
message[3] = "Advice : b +ve";
message[4] = "Advice :Don't b -ve";
}
public static String getAdvice() {
Advisorr r=new Advisorr();
int randomNumber=r.nextInt(message.length);
System.out.println(message[randomNumber]);
}
}
public class greeter2{
public static void main(String[] args) {
Advisorr n = new Advisorr();
System.out.println(n.getAdvice());
}
}
create a class called Advisor that has the following features:
Attributes:
message string[5] //contains five advice messages
Member functions:
Advisor() //default constructor to initialize an array of //strings with
atleast five advice messages
getAdvice() //randomly selects an advice from the available //list of
messages and returns it to the caller of //this method
Can anybody please help debugging and complete the code
Thanks in advance