Assignment Objectives 1. Practice on implementing a MVC project 2. Implement interfaces Deliverables A zipped Java proje

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Assignment Objectives 1. Practice on implementing a MVC project 2. Implement interfaces Deliverables A zipped Java proje

Post by answerhappygod »

Assignment Objectives 1 Practice On Implementing A Mvc Project 2 Implement Interfaces Deliverables A Zipped Java Proje 1
Assignment Objectives 1 Practice On Implementing A Mvc Project 2 Implement Interfaces Deliverables A Zipped Java Proje 1 (44.64 KiB) Viewed 32 times
Assignment Objectives 1 Practice On Implementing A Mvc Project 2 Implement Interfaces Deliverables A Zipped Java Proje 2
Assignment Objectives 1 Practice On Implementing A Mvc Project 2 Implement Interfaces Deliverables A Zipped Java Proje 2 (48.41 KiB) Viewed 32 times
Assignment Objectives 1 Practice On Implementing A Mvc Project 2 Implement Interfaces Deliverables A Zipped Java Proje 3
Assignment Objectives 1 Practice On Implementing A Mvc Project 2 Implement Interfaces Deliverables A Zipped Java Proje 3 (132.34 KiB) Viewed 32 times
Assignment Objectives 1 Practice On Implementing A Mvc Project 2 Implement Interfaces Deliverables A Zipped Java Proje 4
Assignment Objectives 1 Practice On Implementing A Mvc Project 2 Implement Interfaces Deliverables A Zipped Java Proje 4 (37.64 KiB) Viewed 32 times
Assignment Objectives 1 Practice On Implementing A Mvc Project 2 Implement Interfaces Deliverables A Zipped Java Proje 5
Assignment Objectives 1 Practice On Implementing A Mvc Project 2 Implement Interfaces Deliverables A Zipped Java Proje 5 (62.46 KiB) Viewed 32 times
Assignment Objectives 1 Practice On Implementing A Mvc Project 2 Implement Interfaces Deliverables A Zipped Java Proje 6
Assignment Objectives 1 Practice On Implementing A Mvc Project 2 Implement Interfaces Deliverables A Zipped Java Proje 6 (37.34 KiB) Viewed 32 times
Assignment Objectives 1 Practice On Implementing A Mvc Project 2 Implement Interfaces Deliverables A Zipped Java Proje 7
Assignment Objectives 1 Practice On Implementing A Mvc Project 2 Implement Interfaces Deliverables A Zipped Java Proje 7 (82.59 KiB) Viewed 32 times
Assignment Objectives 1 Practice On Implementing A Mvc Project 2 Implement Interfaces Deliverables A Zipped Java Proje 8
Assignment Objectives 1 Practice On Implementing A Mvc Project 2 Implement Interfaces Deliverables A Zipped Java Proje 8 (88.89 KiB) Viewed 32 times
Assignment Objectives 1. Practice on implementing a MVC project 2. Implement interfaces Deliverables A zipped Java project according to the How to submit Labs and Assignments. 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 Implement a Displayable interface. This new interface will help the graphics implementation in the next assignment.
app Creates model, view and controller objects Model private FootballPlayerData fpData; • No parameter constructor • Methods public FootballPlayerData getFpData() public void setFpData(FootballPlayerData fpd) Controller Model model View view All parameter constructor View • No parameter constructor Methods void basicDisplay(String s) * void basicDisplay(ArrayList<String> arr) TableData . • String name • Height height int weight • Person String hometown • String highSchool . Two constructors • Encapsulation • No parameter All parameter • String toString() • Private attributes • Get and set methods implements FootballPlayerData extends Football Player int number String position • Two constructors • No parameter All parameter • Encapsulation ▪ Private attributes • Get and set methods • String toString() public void load Table(); public ArrayList<TableMember> getTable(); public ArrayList<String> getHeaders(); public ArrayList<String>getLine(int line); public ArrayList<ArrayList<String>> getLines(int firstLine, int lastLine); ArrayList<TableMember> players; void ReadPlayersFromXML() {...} public void load Table() {...} public ArrayList<Table Member> getTable() {...) public ArrayList<String> getHeaders() {...} public ArrayList<String> getLine(int line) {...} public ArrayList<ArrayList<String>> getLines(int firstLine, int lastLine) {...} TableMember public String getAttribute(int n) public ArrayList<String>getAttributes() public String getAttributeName(int n) public ArrayList<String>getAttributeNames() implements • int feet Height Int inches • Two constructors ▾ No parameter • All parameter • Encapsulation . Private attributes • Get and set methods. String toString() • Modified to display . 9'99" Displayable public in getFirstline ToDisplay!); public int getLineToHighlight public in getlastline ToDisplay); public int gatinasBeing Displayed: public void setFinLineToDisplay(int firstline) public void setline ToHighlightfin: highlighted line); public void setLastLineToDisplayim last nel pubilc veld setUnesBeingDisplayed Int numberOfLines); implements
Football PlayerData FootballPlayerData will now implement a second interface, called Displayable. public class Football PlayerData implements TableData, Displayable { The NetBeans Project This new assignment brings in a new interface, Displayable. Projects Files Services A04C_Solution FootballPlayer Source Packages <default package> app.java Controller Controller.java Displayable.java FootballPlayer.java FootballPlayerData.java Model Height.java Model.java Person.java TableData.java TableMember.java View View.java <d Controller has a required code. There is a new interface, called Displayable. It has methods that will help a TableData class to display its data graphically.
• <default package> o App.java • Controller o Controller.java • Model o Displayable.java o FootballPlayer.java o Football PlayerData.java o Height.java o Model.java o Person.java o TableData.java o TableMember.java • View o View.java Below is the required initial code in app and in Controller. public class app public static void main(String[] args) View view = new View(); Model model new Model(); Controller controller = new Controller (view, model);
The code for Controller.java ↓ is available. public class Controller { Model model; View view; public controller (View v, Model m) { } } model = m; view = V; //===== string sfltd, slltd, slbd, slth; //display using the default values created by Model, and FootballPlayerData //These values should be set in the Constructor of FootballplayerData //15 lines being displayed with the first line being e sfltd = " " + this.model.getFpData().getFirstLineToDisplay(); slltd="" + this.model.getFpData().getLastLineToDisplay(); slbd="" + this.model.getFpData().getLines BeingDisplayed(); slth = " " + this.model.getFpData().getLineToHighlight(); this.view.basicDisplay("First Line = + sfltd + ", Last Line = " + slltd + ", Lines Being Displayed = " + slbd + ", Line to Highlight=" + slth); //=======▪▪▪▪‒‒‒‒‒‒‒‒‒‒‒‒‒========= //Sets news values and displays them this.model.getFpData().setLinesBeingDisplayed (10); this.model.getFpData().setFirstLineToDisplay(100); sfltd = " " + this.model.getFpData().getFirstLineToDisplay(); slltd="" + this.model.getFpData().getLastLineToDisplay(); slbd = " " + this.model.getFpData().getLines BeingDisplayed (); slth=" " + this.model.getFpData().getLineToHighlight(); this.view.basicDisplay("First Line = " + sfltd + ", Last Line = " + slltd + ", Lines Being Displayed Lines Being Displayed = " + slbd + ", Line to Highlight=" + slth); //=============================== ======== //Sets news values and displays them this.model.getFpData().setLinesBeingDisplayed (20); this.model.getFpData().setFirstLineToDisplay(10); sfltd="" + this.model.getFpData().getFirstLineToDisplay(); slltd="" + this.model.getFpData().getLastLineToDisplay(); slbd = "+ this.model.getFpData().getLinesBeingDisplayed(); slth = "" + this.model.getFpData().getLineToHighlight(); this.view.basicDisplay("First Line = " + sfltd + ", Last Line = " + slltd + ", Lines Being Displayed = " + slbd + ", Line to Highlight=" + s1th); ==== //======▪▪▪▪▪‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒======= //Sets news values and displays them this.model.getFpData().setLinesBeingDisplayed (15); this.model.getFpData().setFirstLineToDisplay(-5); sfltd = "" + this.model.getFpData().getFirstLineToDisplay(); slltd="" + this.model.getFpData().getLastLineToDisplay(); slbd = " " + this.model.getFpData().getLines BeingDisplayed (); slth=""+ this.model.getFpData().getLineToHighlight(); this.view.basicDisplay("First Line = " + sfltd + ", Last Line = " + slltd + ", Lines Being Displayed = " + slbd + ", Line to Highlight=" + s1th); //=============================== ========= //Sets news values and displays them this.model.getFpData().setLinesBeingDisplayed (12); this.model.getFpData().setFirstLineToDisplay (300); sfltd = ""+ this.model.getFpData().getFirstLineToDisplay(); slltd = " " + this.model.getFpData().getLastLineToDisplay(); slbd=""+ this.model.getFpData().getLines BeingDisplayed(); slth = "" + this.model.getFpData().getLineToHighlight(); this.view.basicDisplay("First Line = " + sfltd + ", Last Line = " + slltd + ", Lines Being Displayed = " + slbd + ", Line to Highlight=" + slth);
The code above will test you implementation of the interface Displayable. If your implementation is correct it will generate the display below: First Line = First Line = First Line = First Line = First Line = 0, Last Line = 14, Lines Being Displayed = 15, Line to Highlight= 100, Last Line = 109, Lines Being Displayed = 10, Line to Highlight= 10, Last Line = 29, Lines Being Displayed = 20, Line to Highlight= 0, Last Line = 14, Lines Being Displayed = 15, Line to Highlight= 112, Last Line = 123, Lines Being Displayed = 12, Line to Highlight= Functionality There is a new interface in this project, Displayable • Displayable.java package Model; public interface Displayable public int getFirstLineToDisplay(); public int getLineToHighlight(); public int getLastLineToDisplay(); public int getLinesBeingDisplayed(); public void setFirstLineToDisplay (int firstLine); public void setLineToHighlight(int highlightedLine); public void setLastLineToDisplay (int lastLine); public void setLinesBeingDisplayed (int numberOfLines);
• Displayable.java (make sure you read the FAQ below for more details) o public int getFirstLineToDisplay(); o public void setFirstLineToDisplay(int firstLine); ▪ these first two methods are about an int attribute that will hold the number of the first line to be displayed. The number represents the index of an element in the array of the class that implements the TableData interface. o public int getLineToHighlight(); o public void setLineToHighlight(int highlighted Line); ▪ the two methods above are about an int attribute that will hold the number of the line on the screen that should be highlighted. It will be used only in a later assignment but it is part of the interface and needs to be implemented even if it is not fully functional yet. o public int getLastLineToDisplay(); o public void setLastLineToDisplay(int lastLine); ▪ these two methods are about an int attribute that will hold the number of the last line to be displayed. The number represents the index of an element in the array of the class that implements the TableData interface. o public int getLinesBeing Displayed(); o public void setLinesBeing Displayed (int numberOfLines); ▪ these two methods are about an int attribute that will hold the number of the lines that will appear on the screen at one time. It will be most likely 20 but it should a variable. The application should work with any number of lines. So if this number is set to 10 or 15, this is the number of lines that should appear on the screen.
FAQ - Frequently Asked Questions What are the initial (default) values for the 4 new variables? firstLineToDisplay o for testing purposes, it should be set to O. This is the firs record in the ArrayList to be displayed on the first line on the screen. But any reasonable value is fine. We have 124 records in the ArrayList, so in principle any number from 0 to 123 would work, although last line impose some limits. lastLineToDisplay o Last line is dependent on the values of first line and lines being displayed. linesBeingDisplayed o This is the number of lines on the screen. It should be 15. lineToHighlight o it will not be used in this assignment and can be set to 0. What happens when invalid values (too small-negative or too large-outside the table size) are set to firstLineToDisplay? firstLineToDisplay o when setFirstLineToDisplay receives a negative number ▪ firstLine needs to be set to 0 ▪ lastLine needs to be recalculated based on "0" and on the number of lines being displayed linesBeingDisplayed o when setFirstLineToDisplay receives a number that is larger that the table size (the players ArrayList size) - lines BeingDisplayed ▪ firstLine needs to be set to a number that leaves room to fit linesBeing displayed ▪ lastLine needs to be recalculated based on firstLine and on the number of lines being displayed linesBeingDisplayed
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply