One class, one file. Don’t create multiple classes in the same .java file
Don’t use static variables and methods
Encapsulation: make sure you protect your class variables and provide access to them through get and set methods
all the classes are required to have a constructor that receives all the attributes as parameters and update the attributes accordingly
Follow Horstmann’s Java Language Coding Guidelines
Organized in packages (MVC – Model – View Controller)
The Netbeans Project
You are required to use this NetBeans starter project.
This assignment focus on using the MVC architecture. The main components are the three packages, Model, View and Controller. From the lesson you know that
Functionality
The main objective is to make View display the information about the 5 Person objects. These 5 objects are created in Model in the method loadData( ). Controller will retrieve the data from Model using the method getData(int n) and pass it to View. View will use the method basicDisplay(String s) to display data from each object with the following result:
Controller will try also to get data from an inexistent object (n = 6) and will receive an error message. It will pass the error message to view to be displayed.
You will need to work on Model, Controller, and View adding methods and statements to achieve the assignment objectives.
The classes
App
it has the main method which is the method that Java looks for and runs to start any application
it creates 3 objects, one of the Model class, one of the View class and one of the Controller class.
When it creates Controller, it passes the two other objects as input parameters so that Controller has access to Model and View.
Controller
will retrieve data from Model using the model object to call the method getData (int n)
n = 1 will return the first Person, n =2 the second Person and so on.
after calling all the 5 objects, Controller will try to call a 6th object and should get a string with a error message.
will pass the data from each Person at a time to View, which will display it
the two operations above will work best if Model and View have methods that help with that.
You are writing these methods
For instance, controller might look like this:
Model
it is already given in the starter project although you will need to add some functionality
it needs a method, loadData( ), to load the data, i.e., initialize the 5 Person objects
it needs a method, getData(int n), which returns data about a specific Person (you will write this method or a similar one)
it returns the result of toString for a Person object (from 1 to 5)
any other value of n should return the message “invalid input parameter”
View
In this assignment, it is a very simple class (it will get more complex quickly in the next two assignments)
it just needs to display the text data that it will receive from Controller
It needs a method, basicDisplay (String s), to do this
Person
it is the same as the last assignment, no changes.