Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please complete in netbeans Assignment Objectives 1. Practice on implementing interfaces in Java o FootballPlayerData will implement the interface TableData 2. Overriding methods o when

Please complete in netbeans

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Assignment Objectives 1. Practice on implementing interfaces in Java o FootballPlayerData will implement the interface TableData 2. Overriding methods o when Football PlayerData implements TableData, FootballPlayerData will have to write the real Java code for all the interface abstract methods Deliverables A zipped Java project according to the How to submit Labs and Assignments guide. O.O. 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 constructor that receives all the attributes as parameters and update the attributes accordingly 5. Follow Horstmann's Java Language Coding Guidelines 6. Organized in packages (MVC - Model - View Controller) Contents app Creates model, view and controller objects Person String name Height height . int weight String hometown String highSchool TableData TableMember public String getAttribute(int n) public void load Table(); public ArrayListgetAttributes() public ArrayListgetTable(); public String getAttributeName(int n) public ArrayList getHeaders(); public ArrayListgetAttributeNamesol public ArrayListgetLine(int line); public ArrayList>getLines(int firstLine, int lastline); Model private FootballplayerData fpData; Na parameter constructor . Methods public Football Player Data getFpDatal) public void setFpData(FootballPlayer Data fpd) . . . Two constructors No parameter All parameter implements Controller . Model model View view Encapsulation Private attributes Get and set methods FootballPlayerData ArrayList players; void ReadPlayersFromXMLC ) .--} . All parameter constructor String toString() View No parameter constructor Methods void basicDisplay(strings) void basicDisplay(ArrayList arr) public void loadTable() {...} public ArrayList getTable ) {...} public ArrayList>getLines(int firstLine, int lastLine) (...) extends implements Height int feet Int inches FootballPlayer int number String position Two constructors No parameter All parameter Two constructors No parameter All parameter Encapsulation Private attributes Get and set methods Encapsulation Private attributes Get and set methods String toString) . Modified to display String toString) 9'99" Important There is some code in some classes that are required. My suggestion is that you start with this NetBeans project and add your code to it. Alternatively you can download the Netbeans project above and just copy from it the classes listed below to your own project including the XML file. They are required to have the code as below . Model.java o Controller.java . TableData.java o Football Player.xml NetBeans File Edit View Navigate Source Refactor Run Debug Profile Run Debug Profile Team Tools Window .. A03B Solution Football 249 2 2 @sjava version="1.8.0_121" class="java.beans. XMLDecoder"> nbproject 3 src 3 cobject class="Model. Football Player"> 4 test 5 9 Football Player Table.xml 6 build.xml 7 cint>6manifest.mf 8 9 10 cint>211 12 13 14 e svoid property="highschool"> 15 Dr. Henry A. Wise, Jr. 16 17 e 18 Upper Marlboro, Md. 19 20 cvoid property="name"> 21 Marcus Allens/string> 22 al eunid nrnnert venumer NetBeans File Edit View Navigate Source Refactor Run Debug Profile Team Tools Window Help ACSB Solution follow Data Netbeans 10 8.2 >>> ol - w tbs LLPlayer Theharju while I wall) GE App.java Controller Model o Football Player.java Football PlayerData.java o Height.java o Model.java o Person.java - TableData.java o TableMember.java View o Projects Files Services A03B_Solution_FootballPlayerTable Source Packages App.java Controller Model FootballPlayer.java FootballPlayerData.java Height.java Model.java Person.java TableData.java Table Member.java View Test Packages Libraries Test Libraries Data will be loaded from the XML file (see requirements in the assignment description) Functionality The application App creates a Model object The Model class o creates one FootballPlayer object o displays information to test the newly implemented methods The classes App o 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 model = new Model(); View view = new View(); Controller controller = new Controller(view, model); Controller o will be used to test the new updates in Model and Football PlayerData. public Controller (View v, Model m) { model = m; view = V; view.basicDisplay("-- -"); view.basicDisplay (model.getFpData().getHeaders()); view.basicDisplay("size of headers=" + model.getFpData().getHeaders ().size()); view.basicDisplay("- --"); view.basicDisplay (model.getFpData().getLine(100)); view.basicDisplay("- --"); view.linesDisplay (model.getFpData().getLines (100,103)); view.basicDisplay("size of lines=" + model.getFpData().getLines (100, 103).size()); view.basicDisplay("size of line =" + model.getFpData().getLines (10 0,103).get().size()); view.basicDisplay("-- -----"); } . Model o it needs to be redesigned again to be even more generic than before. o it delegated most of its functions to Football PlayerData o you should use the code of Model.java that is in the starter Netbeans project. private FootballPlayerData fpData; public FootballPlayerData getFpData() public void setFpData(Football Player Data fpd) View o it just needs to display the text data that it will receive from Controller o it has an important new method public void lines Display(ArrayList> arrOfarr) . This method receives an ArrayList of ArrayList for instance, in the test it will receive lines 100,101, 102, and 103 containing FootballPlayer objects data each line contains and ArrayList that can be displayed using the existing method basicDisplay(ArrayList arr). Person o uses encapsulation private attributes . a get and a set method for each attribute o has the following attributes String name; Height height; . int weight; String hometown; String highSchool; o has two constructors . one with no parameters one with all the parameters (one for each attribute) o a toString() method Football Player o has the following attributes . int number; . String position; o two constructors . one with no parameters . one with all the parameters (one for each attribute) o and a method . String toString() . toString() overrides the superclass Object toString() method toString() returns information about this class attributes as a String Height o it is a class (or type) which is used in Person defining the type of the attribute height o uses encapsulation private attributes a get and a set method for each attribute o it has two attributes . int feet: . int inches o two constructors . one with no parameters . one with all the parameters (one for each attribute) o and a method String toString() .toString() overrides the superclass Object toString() method toString() returns information about this class attributes as a String . it returns a formatted String with feet and inches for instance: 5'2" Football PlayerData o you need to start with the code available in the starter Netbeans project o has the following attribute ArrayList players; . this is the array with all the FootballPlayer objects o and the methods coming from the interface Data (these are the methods you need to implement and write the full code for) public void loadTable(); public ArrayList getTable(); public ArrayList getHeaders(); public ArrayList getLine(int line); public ArrayList> getLines(int firstLine, int lastLine); o and a method to read the Football Player objects from a XML and load the ArrayList players public void ReadPlayers FromXMLO) this method will be used in load Table() the method is ready and available in the starter Netbeans project The Interface TableData . it is an interface . remember the interface definition Interfaces are often compared to a contract, to a promise to implement the methods described in the interface. An interface in Java does not have any real code for implemen tation of its methods, it has only the skeleton of the method S. When a class decides to implement an interface, it has to con tain the real code for each method in the interface. . These are the five methods that FootballPlayerData has to implement public void loadTable(); It needs to be called in the constructor to make the table re ady and available right away. It loads real data into the array list. The FootballPlayerData starter class has a method that help w ith this task. The method ReadPlayers FromXML) read the Footballplayer obje cts from an XML file and load them into the players ArrayLis t. public ArrayList getTable(); Returns the full table of data. public ArrayList getHeaders(); The method will return an ArrayList of Strings with the names of the FootballPlayer fields (the "headers"). public ArrayList getLine(int line); The method will return an ArrayList of Strings with the value s of the FootballPlayer object in a chosen line "n" in the ta ble. public ArrayList> getLines(int firstLine, i nt lastLine); This methods used the getLine() method. It gets a set of lin es (each one of them an array of Strings) from getLine( int n) and adds them to an array of arrays. It returns this array of arrays. A strategy . In the same you you did in the last assignment, here already developed methods can help you in writing new methods. getLine(int line) can use FootballPlayer getAttributes() getHeaders() can use Football Player getAttributeNames getLines(int firstLine, int lastLine) can use FootballPlayerData getLine(int line) The Expected Output number position name height weight hometown highSchool size of headers=7 62 G Zach Simpson 6'3" 272 Hollidaysburg, Pa. Hollidaysburg Area 62 G Zach Simpson 6'3" 272 Hollidaysburg, Pa. Hollidaysburg Area 24 S Anthony Smith 6'0" 206 Dover, N.J. Pope John XXIII 47 LB Brandon Smith 6'0" 223 Winfield, Pa. Lewisburg size of lines=3 size of line 6=7 Assignment Objectives 1. Practice on implementing interfaces in Java o FootballPlayerData will implement the interface TableData 2. Overriding methods o when Football PlayerData implements TableData, FootballPlayerData will have to write the real Java code for all the interface abstract methods Deliverables A zipped Java project according to the How to submit Labs and Assignments guide. O.O. 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 constructor that receives all the attributes as parameters and update the attributes accordingly 5. Follow Horstmann's Java Language Coding Guidelines 6. Organized in packages (MVC - Model - View Controller) Contents app Creates model, view and controller objects Person String name Height height . int weight String hometown String highSchool TableData TableMember public String getAttribute(int n) public void load Table(); public ArrayListgetAttributes() public ArrayListgetTable(); public String getAttributeName(int n) public ArrayList getHeaders(); public ArrayListgetAttributeNamesol public ArrayListgetLine(int line); public ArrayList>getLines(int firstLine, int lastline); Model private FootballplayerData fpData; Na parameter constructor . Methods public Football Player Data getFpDatal) public void setFpData(FootballPlayer Data fpd) . . . Two constructors No parameter All parameter implements Controller . Model model View view Encapsulation Private attributes Get and set methods FootballPlayerData ArrayList players; void ReadPlayersFromXMLC ) .--} . All parameter constructor String toString() View No parameter constructor Methods void basicDisplay(strings) void basicDisplay(ArrayList arr) public void loadTable() {...} public ArrayList getTable ) {...} public ArrayList>getLines(int firstLine, int lastLine) (...) extends implements Height int feet Int inches FootballPlayer int number String position Two constructors No parameter All parameter Two constructors No parameter All parameter Encapsulation Private attributes Get and set methods Encapsulation Private attributes Get and set methods String toString) . Modified to display String toString) 9'99" Important There is some code in some classes that are required. My suggestion is that you start with this NetBeans project and add your code to it. Alternatively you can download the Netbeans project above and just copy from it the classes listed below to your own project including the XML file. They are required to have the code as below . Model.java o Controller.java . TableData.java o Football Player.xml NetBeans File Edit View Navigate Source Refactor Run Debug Profile Run Debug Profile Team Tools Window .. A03B Solution Football 249 2 2 @sjava version="1.8.0_121" class="java.beans. XMLDecoder"> nbproject 3 src 3 cobject class="Model. Football Player"> 4 test 5 9 Football Player Table.xml 6 build.xml 7 cint>6manifest.mf 8 9 10 cint>211 12 13 14 e svoid property="highschool"> 15 Dr. Henry A. Wise, Jr. 16 17 e 18 Upper Marlboro, Md. 19 20 cvoid property="name"> 21 Marcus Allens/string> 22 al eunid nrnnert venumer NetBeans File Edit View Navigate Source Refactor Run Debug Profile Team Tools Window Help ACSB Solution follow Data Netbeans 10 8.2 >>> ol - w tbs LLPlayer Theharju while I wall) GE App.java Controller Model o Football Player.java Football PlayerData.java o Height.java o Model.java o Person.java - TableData.java o TableMember.java View o Projects Files Services A03B_Solution_FootballPlayerTable Source Packages App.java Controller Model FootballPlayer.java FootballPlayerData.java Height.java Model.java Person.java TableData.java Table Member.java View Test Packages Libraries Test Libraries Data will be loaded from the XML file (see requirements in the assignment description) Functionality The application App creates a Model object The Model class o creates one FootballPlayer object o displays information to test the newly implemented methods The classes App o 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 model = new Model(); View view = new View(); Controller controller = new Controller(view, model); Controller o will be used to test the new updates in Model and Football PlayerData. public Controller (View v, Model m) { model = m; view = V; view.basicDisplay("-- -"); view.basicDisplay (model.getFpData().getHeaders()); view.basicDisplay("size of headers=" + model.getFpData().getHeaders ().size()); view.basicDisplay("- --"); view.basicDisplay (model.getFpData().getLine(100)); view.basicDisplay("- --"); view.linesDisplay (model.getFpData().getLines (100,103)); view.basicDisplay("size of lines=" + model.getFpData().getLines (100, 103).size()); view.basicDisplay("size of line =" + model.getFpData().getLines (10 0,103).get().size()); view.basicDisplay("-- -----"); } . Model o it needs to be redesigned again to be even more generic than before. o it delegated most of its functions to Football PlayerData o you should use the code of Model.java that is in the starter Netbeans project. private FootballPlayerData fpData; public FootballPlayerData getFpData() public void setFpData(Football Player Data fpd) View o it just needs to display the text data that it will receive from Controller o it has an important new method public void lines Display(ArrayList> arrOfarr) . This method receives an ArrayList of ArrayList for instance, in the test it will receive lines 100,101, 102, and 103 containing FootballPlayer objects data each line contains and ArrayList that can be displayed using the existing method basicDisplay(ArrayList arr). Person o uses encapsulation private attributes . a get and a set method for each attribute o has the following attributes String name; Height height; . int weight; String hometown; String highSchool; o has two constructors . one with no parameters one with all the parameters (one for each attribute) o a toString() method Football Player o has the following attributes . int number; . String position; o two constructors . one with no parameters . one with all the parameters (one for each attribute) o and a method . String toString() . toString() overrides the superclass Object toString() method toString() returns information about this class attributes as a String Height o it is a class (or type) which is used in Person defining the type of the attribute height o uses encapsulation private attributes a get and a set method for each attribute o it has two attributes . int feet: . int inches o two constructors . one with no parameters . one with all the parameters (one for each attribute) o and a method String toString() .toString() overrides the superclass Object toString() method toString() returns information about this class attributes as a String . it returns a formatted String with feet and inches for instance: 5'2" Football PlayerData o you need to start with the code available in the starter Netbeans project o has the following attribute ArrayList players; . this is the array with all the FootballPlayer objects o and the methods coming from the interface Data (these are the methods you need to implement and write the full code for) public void loadTable(); public ArrayList getTable(); public ArrayList getHeaders(); public ArrayList getLine(int line); public ArrayList> getLines(int firstLine, int lastLine); o and a method to read the Football Player objects from a XML and load the ArrayList players public void ReadPlayers FromXMLO) this method will be used in load Table() the method is ready and available in the starter Netbeans project The Interface TableData . it is an interface . remember the interface definition Interfaces are often compared to a contract, to a promise to implement the methods described in the interface. An interface in Java does not have any real code for implemen tation of its methods, it has only the skeleton of the method S. When a class decides to implement an interface, it has to con tain the real code for each method in the interface. . These are the five methods that FootballPlayerData has to implement public void loadTable(); It needs to be called in the constructor to make the table re ady and available right away. It loads real data into the array list. The FootballPlayerData starter class has a method that help w ith this task. The method ReadPlayers FromXML) read the Footballplayer obje cts from an XML file and load them into the players ArrayLis t. public ArrayList getTable(); Returns the full table of data. public ArrayList getHeaders(); The method will return an ArrayList of Strings with the names of the FootballPlayer fields (the "headers"). public ArrayList getLine(int line); The method will return an ArrayList of Strings with the value s of the FootballPlayer object in a chosen line "n" in the ta ble. public ArrayList> getLines(int firstLine, i nt lastLine); This methods used the getLine() method. It gets a set of lin es (each one of them an array of Strings) from getLine( int n) and adds them to an array of arrays. It returns this array of arrays. A strategy . In the same you you did in the last assignment, here already developed methods can help you in writing new methods. getLine(int line) can use FootballPlayer getAttributes() getHeaders() can use Football Player getAttributeNames getLines(int firstLine, int lastLine) can use FootballPlayerData getLine(int line) The Expected Output number position name height weight hometown highSchool size of headers=7 62 G Zach Simpson 6'3" 272 Hollidaysburg, Pa. Hollidaysburg Area 62 G Zach Simpson 6'3" 272 Hollidaysburg, Pa. Hollidaysburg Area 24 S Anthony Smith 6'0" 206 Dover, N.J. Pope John XXIII 47 LB Brandon Smith 6'0" 223 Winfield, Pa. Lewisburg size of lines=3 size of line 6=7

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

Master The Art Of Data Storytelling With Visualizations

Authors: Alexander N Donovan

1st Edition

B0CNMD9QRD, 979-8867864248

More Books

Students also viewed these Databases questions