Question: App -Creates a SoccerPlayer object spo using the no-parameter constructor. - Creates a Soccer Player object spl using the all-parameter constructor. - Creates a Football

 App -Creates a SoccerPlayer object spo using the no-parameter constructor. -Creates a Soccer Player object spl using the all-parameter constructor. - Createsa Football Player object fp using the no-parameter constructor. - Creates aFootball Player object fp1 using the all-parameter constructor. - Using the methodtoString(), display all the data from each of the 4 objects. ZipCodeAttributes private String five Digit; private String plus4; Person Attributes private Stringname; private Address address: Constructors No-parameter All-parameter Methods String toString) Get/Set methodsextends abstract Player Attributes private int number; private String sports; Private intgames Played; Constructors No-parameter . All parameter Methods String toString) Get/Set methodsabstract double getRatings(); Address Attributes private int number; private String name: privateString type; private ZipCode zip: private String state; . . Constructors No-parameter

App -Creates a SoccerPlayer object spo using the no-parameter constructor. - Creates a Soccer Player object spl using the all-parameter constructor. - Creates a Football Player object fp using the no-parameter constructor. - Creates a Football Player object fp1 using the all-parameter constructor. - Using the method toString(), display all the data from each of the 4 objects. ZipCode Attributes private String five Digit; private String plus4; Person Attributes private String name; private Address address: Constructors No-parameter All-parameter Methods String toString) Get/Set methods extends abstract Player Attributes private int number; private String sports; Private int games Played; Constructors No-parameter . All parameter Methods String toString) Get/Set methods abstract double getRatings(); Address Attributes private int number; private String name: private String type; private ZipCode zip: private String state; . . Constructors No-parameter One-parameter Two-parameter Methods String toString() Get/Set methods void display() void displayPrefix(int p) Constructors No-parameter All-parameter Methods String toString() Get/Set methods extends SoccerPlayer Attributes private int goals; private int yellow Cards; Constructors No-parameter All-parameter Football Player Attributes private int yards; private minutesPlayed Constructors No-parameter All-parameter Methods String toString() Get/Set methods double getRatings Methods String toString() Get/Set methods double getRatings() The Person Class Uses encapsulation 1. Attributes o private String name o private Address address 1. Constructors o one constructor with no input parameters since it doesn't receive any input values, you need to use the default values below: name - "John Doe" address - use the default constructor of Address o one constructor with all (two) parameters one input parameter for each attribute 2. Methods public String toString() returns this object as a String, i.e., make each attribute a String, concatenate all strings and return as one String. .toString() is a special method, you will learn more about it in the next lessons . it needs to be public . it needs to have @override notation (on the line above the method itself). Netbeans will suggest you do it. Get and Set methods public int getName() public void setName(String name) public Address getAddress() public void setAddress(Address address) o The Player Class (with updates from the last lab) Player is a person with some extra attributes Uses encapsulation Player now is an abstract class because it has an abstract method o public double getRatings(); an abstract method is an incomplete method that has to be implemented by the subclasses. 1. Attributes private int number private String sports private gamesPlayed 1. Constructors one constructor with no input parameters since it doesn't receive any input values, you need to use the default values below: number - 0 sports - "none" gamesPlayed - 0 one constructor with all (three) parameters one input parameter for each attribute 2. Methods public String toString() returns this object as a String, i.e., make each attribute a String, concatenate all strings and return as one String. toString() is a special method, you will learn more about it in the next lessons it needs to be public it needs to have @override notation (on the line above the method itself). Netbeans will suggest you do it. . Get and Set methods public int getNumber() public void setNumber(int number) public String getSports() public void setSports(String sports) public int getGamesPlayed() public void setGamesPlayed(int gamesPlayed) . public abstract getRatings(); . The Soccer Player Class SoccerPlayer is a Player with some extra attributes Uses encapsulation SoccerPlayer will implement the method getRatings (an abstract method from the superclass Player) toString has to include the result of getRatings() too 1. Attributes o private int goals private int yellow Cards 1. Constructors one constructor with no input parameters since it doesn't receive any input values, you need to use the default values below: goals - 0 - yellow Cards - 0 one constructor with all (two) parameters one input parameter for each attribute 2. Methods public String toStringo returns this object as a String, i.e., make each attribute a String, concatenate all strings and return as one String. .toString() is a special method, you will learn more about it in the next lessons . it needs to be public . it needs to have @override notation on the line above the method itself). Netbeans will suggest you do it. should also include the value of getRatings() in the string Get and Set methods public int getGoals() public void set Goals(int goals) public int getYellow Cards() public void setYellow Cards(int yellow Cards) o public double getRatings() calculate and return the rates using this formula: . (double) (goals - yellow Cards)/gamesPlayed the (double) is called casting, forcing the expression that comes afterwards to become a double. . it is necessary to avoid getting O as a result because of the precision loss in the division by integers . if goals or gamesPlayed is O, return Olyou need to do this test to avoid the application crashing in case one of them is 0) The FootballPlayer Class FootballPlayer is a Player with some extra attributes Uses encapsulation FootballPlayer will implement the method getRatings (an abstract method from the superclass Player) .toString has to include the result of getRatings() too 1. Attributes private int yards o private int minutes Played 1. Constructors o one constructor with no input parameters since it doesn't receive any input values, you need to use the default values below: yards - 0 minutesPlayed - O o one constructor with all (two) parameters one input parameter for each attribute 2. Methods o public String toString() returns this object as a String, i.e., make each attribute a String, concatenate all strings and return as one String. .toString() is a special method, you will learn more about it in the next lessons . it needs to be public . it needs to have moverride notation (on the line above the method itself). Netbeans will suggest you do it. should also include the value of getRatings() in the string Get and Set methods public int getYards() public void getYards(int yards) public int getMinutesPlayed) public void set Minutes Played(int minutesPlayed) o public double getRatings() calculate and return the rates using this formula: . (double) ( (yards - minutesPlayed/10.0) ) /gamesPlayed . be careful with the parenthesis to avoid getting O as a result - the (double) is called casting, forcing the expression that comes afterwards to become a double. . it is necessary to avoid getting as a result because of the precision loss in the division by integers use 10.0 instead of 10 to force Java to use more precision in the calculation if yards or gamesPlayed is O, return O(you need to do this test to avoid the application crashing in case one of them is 0) The Address Class Uses encapsulation 1. Attributes private int number private String name private String type private Zip Code zip o private String state 1. Constructors one constructor with no input parameters since it doesn't receive any input values, you need to use the default values below: number - 0 name - "N/A" type - "Unknown" zip - use the default constructor of ZipCode state -" "(two spaces) . one constructor with all (five) parameters one input parameter for each attribute 2. Methods public String toStringo returns this object as a String, i.e., make each attribute a String, concatenate all strings and return as one String. toString() is a special method, you will learn more about it in the next lessons . it needs to be public . it needs to have @override notation on the line above the method itself). Netbeans will suggest you do it. . Get and Set methods public int getNumber() public void setNumber(int number) public String getName() public void setName(String name) . this method will receive an input parameter name and will correct if necessary to make its first letter upper case and the remaining part of the word lower case (correcting MAIN to Main, for instance) - it will work for at least 2 words correcting north atherton to North Atherton, for instance) . the attribute name will be updated with the corrected value public String getType() this method will return a corrected value depending on the value of the attribute type. it will return "Dr." if the attribute type is "Drive" it will return "Ave." if the attribute type is "Avenue" . it will return "St." if the attribute type is "Street" . it will return the value of the attribute type for any other cases public void setType(String type) public ZipCode getZipo) public void setZip(Zip Code zip) public String getState() public void setState(String state) . . The Zip Code Class (updated to include encapsulation) Uses encapsulation 1. Attributes private String five Digit private String plus4 2. Constructors one constructor with no input parameters since it doesn't receive any input values, you need to use the default values below: private fiveDigit - "00000" private plus4 - "0000" one constructor with one parameter . one input parameter for five Digit use the default value from the no-parameter constructor to initialize plus4 o one constructor with all (two) parameters one input parameter for each attribute 3. Methods (updated to include Get and Set methods) o public String toStringo returns this object as a String, i.e., make each attribute a String, concatenate all strings and return as one String. .toString() is a special method, you will learn more about it in the next lessons . it needs to be public - it needs to have @override notation (on the line above the method itself). Netbeans will suggest you do it. the toString method will have a similar functionality as App had in the first lab. . it returns all the data from each object as a String . if the second attribute, plus4, is blank, display only the first attribute fivedigit, for instance, 16801 if the second attribute, plus4, is not blank, display only the first attribute fivedigit followed by a "-" and then the plus4 attribute, for instance, 16802-1503 . Get and Set methods for each of the two attributes displayo . this method gets the "toString()" value (whatever is returned by toString()) and uses "System.out.println" to display it. you need to decide what is the type of this method displayPrefix(int p) . this method receives an input parameter, an int number p based on p's value . if p's value is 1 uses "System.out.println" to display the zipcode's prefix, i.e., its 3 first digits. . if the fiveDigit is "10022", displays "100" - if p's value is2 uses "System.out.println" to display the zipcode's area, i.e., its fourth and fifth digits. . if the five Digit is "10022", displays "22" for any other value of p, it should not display anything The App class 1. create a Soccer Player object spo using the no-parameter constructor 2. create a SoccerPlayer object sp1 using the all-parameter constructor with the value o name "Julia Dohle" address number - 210 name - Old Main type - Street .zip fiveDigit - 16802 plus4 - 0001 state - PA number - 7 sports - "Soccer" gamesPlayed - 10 goals - 5 yellow Cards - 1 3. create a FootballPlayer object fpo using the no-parameter constructor 4. create a Football Player object fp1 using the all-parameter constructor with the value name "Saquon Barkley" address number - 210 name - Old Main type - Street zip fiveDigit - 16802 plus4 - 0001 state - PA o number - 26 sports - "Football games Played - 10 yards - 80 minutesPlayed - 220 5. display all the data from each object using the method toString() Output Important you need to display each class toString() in a separate line. You can do this by adding a " " at the end of the string. In the last toString you will also add a "= =.." string to close the line. The output should be similar to Person{name=John Doe, address=Address{number=0, name=N/A, type=Unknown, zip=00000, state= }} Player{number=0, sports=none, gamesPlayed=0} SoccerPlayer{goals=0, yellowCards=0, ratings= 0.0} ===== Person{name=Julia Dohle, address=Address{number=210, name=01d Main, type=St., zip=16802-9001, state=PA}} Player{number=7, sports-Soccer, gamesPlayed=10} SoccerPlayer{goals-5, yellowCards=1, ratings= 0.4} ===== Person{name=John Doe, address=Address(number=0, name=N/A, type=Unknown, zip=00000, state= }} Player{number=0, sports=none, gamesPlayed=0} FootballPlayer{yards=0, minutesPlayed=0, ratings=0.0} ==EEEEE Person{name=Saquon Barkley, address=Address{number=210, name=01d Main, type=St., zip=16802-0001, state=PA}} Player{number=26, sports=Football, gamesPlayed=10} FootballPlayer{yards=80, minutesPlayed=220, ratings=5.8} ================ ========= =========

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!