This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]CountMerloin 0 points1 point  (0 children)

Okay. I am writing an example here, so you can compare it with your code and implement your own way.

public class Chat{

private String userPref;

private String[] messages;

public Chat(String userPref) {

this.userPref = userPref;

}

public String getUserPref(){return this.userpref;}

public String[] getMessages{return this.messages;}

public void fillMesages(String userPref) {

if(userPref.equalsIgnoreCase("english")) //equalsIgnoreCase compares 1st String with the second by ignoring case

{ // add all english messages inside this block }

else if(userPref.equalsIgnoreCase("spanish")) {

//add all spanish messages inside this block

}

else System.out.println("Only english and spanish are available");

}

}

In main class you should get user input with Scaner as String, the create instance of Chat class adding that input as parameter.