Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Interface it is an interface remember the interface definition Interfaces are often compared to a contract, to a promise to implement the methods described

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

The Interface

  • 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 implementation of its methods, it has only the skeleton of the methods. When a class decides to implement an interface, it has to contain the real code for each method in the interface. 
  • These are the five methods that FootballPlayerData has to implementf
    • public void loadTable(); It needs to be called in the constructor to make the table ready and available right away. It loads real data into the array list. The FootballPlayerData starter class has a method that help with this task. The method ReadPlayersFromXML( ) read the FootballPlayer objects from an XML file and load them into the players ArrayList. 
    • public ArrayList getTable(); Returns the full table of data. Although right now is not required, soon you will need this method to return a specific ArrayList instead of a generic ArrayList. 
    • 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 values of the FootballPlayer object in a chosen line "n" in the table.
    • public ArrayList> getLines(int firstLine, int lastLine); This methods used the getLine( ) method. It gets a set of lines (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.
Do not use the scanner class or any other user input request. You application should be self-contained and run without user input. Assignment Objectives 1. Practice on implementing interfaces in Java o Football Player Data will implement the interface TableData 2. Overriding methods o when Football Player Data implements TableData, Football Player Data 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 TableData public void load Table(); public ArrayList getTable(); public ArrayList getHeaders(); public ArrayListgetLine(int line); public ArrayList>getLines(int firstLine, int lastline); A implements FootballPlayerData ArrayList players; void Read Players FromXML() {...} public void loadTable() {...} public ArrayList getTable() {...} public ArrayList getHeaders() {...} public ArrayListgetLine(int line) {...} public ArrayList>getLines(int firstLine, int lastline) {...}| Football Player Data will implement the interface TableData writing real code for all the abstract methods. TableMember Person String name Height height int weight String hometown String highSchool public String getAttribute(int n); public ArrayListgetAttributes(); public String getAttributeName(int n); public ArrayListgetAttributeNames(); String toString() extends implements Height int feet int inches Football Player int number String position String toString() {...} public String getAttribute(int n){...} public ArrayListgetAttributes() {...} public String getAttributeName(int n) {...} public ArrayListgetAttributeNames() {...} String toString() Football Player will implement the interface TableMember writing real code for all the abstract methods. app Model model = new Model(); Model FootballPlayerData fpData = new Football PlayerData(); System.out.println(fpData.getHeaders().toString()); System.out.println(fpData.getLine(50).toString()); ArrayList> lines = fpData.getLines(0, 4); for (int i = 0; i java version 1.0.0 121" classejava beans. object class Model. Football Player vod property" height cobject classe Hotel Height"> void property intint FootbalPlayerTable.xml vaid property voice void property School string Or. Henry A. Wise, Jr./string void propertyasane Marcus Allen st dator > Teenuste trottlaer decorrente The the a XML file with all the Football Player objects coded in XML. The method Read Players FromXML (which is ready) reads this file and create the Football Player objects that will be loaded in the ArrayList. The method ReadPlayersFromXML() requires that the classes it uses (Football Player, Height, and Person) o have an empty constructor (besides the "regular" constructor you are using o have all getters and setters (and you should already if you are using the required encapsulation) Bring the remaining classes from your previous assignment: Football Player.java (should be implementing TableMember as per requirements of the previous assignment) 1. with an extra empty constructor, it needs to be explicitly declared "public" 2. all the attributes have to have the exact same names as described in the assignment 3. all the attributes have to have getters and setters Height.java 1. with an extra empty constructor, it needs to be explicitly declared "public" 2. all the attributes have to have the exact same names as described in the assignment 3. all the attributes have to have getters and setters Person.java 1. with an extra empty constructor, it needs to be explicitly declared "public" 2. all the attributes have to have the exact same names as described in the assignment 3. all the attributes have to have getters and setters NetBeans File Edit View Nav App.java Controller (not being used in this lab) Model Football Player.java o Football PlayerData.java o Height.java o Model.java o Person.java o TableData.java o TableMember.java View (not being used in this lab) Projects Files Services A03B_Solution_FootballPlayerTable Source Packages 8 App.java Controller 3 Model FootballPlayer.java FootballPlayerData.java Height.java Model.java Person.java TableData.java - Table Member.java View Test Packages Libraries Test Libraries Functionality The application App creates a Model object The Model class o creates one Football Player 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 an object (an instance) of the Model class . Model o has to have the code below package Model; import java.util.ArrayList; public class Model public Model() ==="); FootballPlayerData fpData = new FootballPlayerData(); System.out.println("============================== System.out.println(fpData.getHeaders().toString(); System.out.println(" =========== = = = ===== System.out.println(fpData.getLine(50).toString(); System.out.println("========= ArrayList> lines = fpData.getLines (@, 4); for (int i = 0; i players; . this is the array with all the Football Player 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 load Table(); public ArrayList getTable(); public ArrayList getHeaders(); public ArrayListgetLine(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 Read PlayersFromXMLC) this method will be used in load Table() the method is ready and available in the Football Player Data starter file

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

Question

explain what is meant by the terms unitarism and pluralism

Answered: 1 week ago