1. Create
a folder named ‘mvc’ where you would like to store your files.
2. On
your textpad, create a file named Main.java, save it to your folder ‘mvc’ and
type the following:
class Main{
public static void main(String[] args){
ContactsView
view = new ContactsView();
ContactsController controller = new
ContactsController(view);
}
}
3. Create
another file named ContactsView.java and type the following:
class ContactsView{
public ContactsView(){
}
private void
println(String str){
System.out.println(str);
}
public void menu(){
println("---Menu---");
println("1. Add Contact");
println("2. Edit Contact");
println("3. Delete Contact");
println("0. Quit");
println("Select Menu[0-3]: ");
}
}
4. Create
another file named ContactsController.java and type the following:
class ContactsController{
ContactsView view;
public ContactsController(ContactsView view){
this.view = view;
viewUI();
}
private void viewUI(){
view.menu();
}
}

No comments:
Post a Comment