Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please do 0.0. Requirements (these items will be part of your grade) 1. One class, one file. Don't create multiple classes in the same .java

please do
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
0.0. Requirements (these items will be part of your grade) 1. One class, one file. Don't create multiple classes in the same .java file 2. Don't use static variables and methods 3. Encapsulation: make sure you protect your class variables and provide access to them through get and set methods 4. all the classes are required to have a app Creates model, view and controller objects Model Person p1.p2.p3,p4,p5 No parameter constructor Methods void loadData() String getData(int n) Person String name int weight String hometown String highSchool Two constructors No parameter . All parameter Controller Model model View view Encapsulation Private attributes Get and set methods All parameter constructor String toString() View No parameter constructor Methods void basicDisplay(String s) landet Controller calls the method getDatafinn) town Penen objects a String Model creates Person objects In total Model will have a method getDatint to retrieven Person object as a Sering a Castrella App creates a Model object and a view object and pass them as parameters when It creates a Controller object. im Vi Controlleras the data red from Modelo View for to be View will have a method bashlayString to diplay the string on the default window The Netbeans Project View objects are objects that the users can see, the graphical part of an application Model objects will have all the data and processing needs of an application The Controller objects will usually help and support the communication and data transfer betwe en Model and View objects. App creates Model and View objects. Then it creates a Controller object passing the model and view objects as input parameters to controller The Controller package has the Controller class. Controller has access to model and view and is in charge of bringing data from Model and sending it to view. Projects Files Services L01 MVC Source Packages D o App.java Projects Files Services LO1_b_MVC Source Packages Test Libraries Data The Model class will create 5 Person objects using the full-parameter constructor with the data below name=Marcus Allen, weight-200, hometown-Upper Marlboro, Md., highSchoolDr. Henry A. Wise, Jr. name-Kyle Alston, weight=180, hometown-Robbinsville, N.J., highSchool-Robbinsville name=Troy Apke, weight=220, hometown-Mt. Lebanon, Pa., highSchool-Mount Lebanon .name=Matthew Baney, weight-225. hometown=State College, Pa., highSchool-State College using the no-parameter constructor 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 String getData(int n) and pass it to View.View will use the method void basicDisplay(String s) to display data from each object with the following result Person{name-Marcus Allen, weight-200, hometown Upper Marlboro, Md., highschool-Dr. Henry A. WE se, Jr. Person{name-Kyle Alston, weight-180, hometown-Robbinsville, N.J., highschool-Robbinsville) Person{name=Troy Apke, weight-220, hometown Mt. Lebanon, Pa., highSchool-Mount Lebanon Person{name Matthew Baney, weight-225, hometown-State College, Pa., highSchool-State College) Person (name, weight-, hometown-N/A, highSchool N/A} invalid input parameter Controller will try also to get data from an inexistent object (n = 6) and will receive an error message will massithe emer message to view the 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 o 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. model - new Modelo: View view = new View: Controller controller = new Controller(model, view) Controller o will retrieve data from Model using the model object to call the method String getData(int n) . n = 1 will return the first Person, n=2 the second Person and so on. after calling all thels objects, Controller will try to call a 6th object and should get a string with a error message. o 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 o For instance, controller might look like this: Controller o will retrieve data from Model using the model object to call the method String 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. o 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: view.basicDisplayCmodel.getData(1)); view.basicDisplay(model getData(2)); view.basicDisplay(model.getData(6): Model o it is already given in the starter project although you will need to add some functionality o it needs a method, loadData(), to load the data, i.e., initialize the 5 Person objects o it needs a method, String 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 needs a method, loadData), to load the data, i.e. Initialize the 5 Person objects o it needs a method, String 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) o it just needs to display the text data that it will receive from Controller It needs a method, vold basicDisplay (Strings) to do this Person o it is the same as the last assignment, no changes Output The output will look like this: Person[name-Marcus Allen, weight-200, hometownupper Marlboro, Md., highschool-Dr. Henry A. W se, Jr.) Person{name-kyle Alston, weight-180, hometown-Robbinsville, N.)., highSchool-Robbinsville) Person{name-Troy Apke, weight-220, hometown Mt. Lebanon, Pa., highschool Mount Lebanon) Person[name Matthew Baney, weight-225, hometown-State College, Po,, highschool-State College) Person{name, weight-, hometown=N/A, highSchool -N/A) invalid input parameter

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions