Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this is all information for the project. Instructions You must complete the Blanket Honesty Declaration checklist on the course website before you can submit any

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

this is all information for the project.

Instructions You must complete the "Blanket Honesty Declaration checklist on the course website before you can submit any assignment. You will not be able to see the dropbox if you have not accepted the Honesty Declaration Only submit the java files. Do not submit any other files, unless otherwise instructed To submit the assignment, upload the specified files to the Assignment 1 folder on the course website. Assignments must follow the programming standards document published on UMLearn. After the due date and time, assignments may be submitted but will be subject to a late penalty. Please see the ROASS document published on UMLearn for the course policy for late submissions If you make multiple submissions, only the most recent version will be marked. These assignments are your chance to learn the material for the exams. Code your assignments independently. We use software to compare all submitted assignments to each other, and pursue academic dishonesty vigorously Your Java programs must compile and run upon download, without requiring any modifications Assignment overview In this assignment, you will implement a set of related classes of objects: Player: A Laser Tag player Team: A team of Laser Tag players Game: A game of Laser Tag between two teams Location: A Laser Tag venue, which players can be members of Keep all of your methods short and simple. In a properly-written object-oriented program, the work is distributed among many small methods, which call cach other. There are no methods in this entire assignment that should require more than 10 lines of code, not counting comments, blank lines, or lines (and many of them need no more than 3). Unless specified otherwise, all Instance variables must be private, and all methods should be public. Also, unless specified otherwise, there should be no printin statements in your classes. Objects usually do not print anything, they only return String values from toString methods Your code should be DRY- don't repeat yourself. If you have a method that already accomplishes a task, or has some logic, that logic should be used. You may add any private methods you see fit to help accomplish this task. The description of the assignment has methods that are required. There are suggested names for the parameters, which you may change. Do not change the signatures of the methods. Your classes and objects should work with the pravided test files You may not use an ArrayList in this assignment. You may write your own collection class, but that is not the expectation for this assignment. Testing Your Coding We have provided sample test files for each phase to help you see if your code is working according to the assignment specifications. These files are starting points for testing your code Part of developing your skills as a programmer is to think through additional important test cases and to write your own code to test these cases. Different, more vigorous tests will be used to test your program. Sample output is provided in some cases, for you to match as closely as possible. Other output is left out, for you to practice reading code, understand a program, and practice seeing it output is correct or not based on inputs. Phase 1: Class Player This class represents a Laser Tag player in our system. The class tracks the user's name, how many games they have played, and can calculate their average score. You will need to make instance varables to keep this information in your objects Class player requires the following methods: A constructor public Player(String nane). Initialize other instance variables as required Methed public void addGameResult(int newscore). This method is called after a game is played, the value passed is added to the user's average that is being bracked by this object public boolean equals(Player other), which checks equality of two Player objects. TWO Player Objects are equalif the names of the two Players are the same A tostring method that prints out information of the object of the player has not played any Eames print that the player has not played any games. If they player has played some games, print out the player's game average score. Use integer division to calculate the average. See the sample output, and match it as closely as possible. Accessor method gmt.Name(), which runs the player's name Sample output: Should print "Players Jim Beam has played no games Player: Jim Beam tas played no games Should print "Player: Johnny Walker has played no games" Player: Johnny Walker has played no games Should print "Player: Jim Beam has played i game with an average of SO" Player Jim Beam has played i game with an average of 50 Should print "Player: Jim Beam has played 2 games with an average of 52 Player: Jim Beam las played 2 games with an average of 51 Should print "Player: Johnny Walker has played 50 games with an average of 25 Player: Johnny Walker has played 50 games with an average of 25 true false Hello, my name is Jim Beam Phase 2: Class Team Create class Team, which is a collection of players who play Laser Tag games. Teams have maximum sizes and players that come and go from the team. Use a partially-filled array to keep track of the players on the team. - Create a constant to track the maximum size of the team Set the constant to 5 Add a constructor, that has no parameters, if you need are Add method public boolean addMember(Player nene), which adds a player to the team A player can be added to a team : the player is not already or the team and there is space left in the team. Players can be a part of more than one tean. Add method public String costring(), which prints out the team roster. See sample output for the format required. Add method public boolean hasCommon Players (Team other), which returns true if there is a player that is on the roster of both teams Methed public boolean teampull(), which returns true if the team has a full complement of members. Use the constant you used for maximum size of the team to determine this Method public boolean remove Player(Player toRemove), which removes a player from the team. Method public player getRosterl) which returns a deep copy of the team. The returned array should be the same sees the number of players. For instance, if there is only 1 member on the team, the returned array should return an array of size 1. You do not have to do a recursive deep copy, that is you do not have to deep copy the Player objects - just the array Sample output: Teams 1: Ashley Johnson Teens 1. Ashley Johnson 2: Laura Bailey Tember: 1. Ashley Johnson 2: Laura Bailey Team members: 1: Ashley Johnson 2. Laura Bailey 3: Liam O'Brien 4: Narisha Ray false Team members: 1: Ashley Johnson 21 Laura Bailey 3: Lla. O'Brien 4: Maripa Ray 5: Riegel LE true Team members: 1. Ashley Johnson 2: Laura Bailey 3: Liam O Brien 4: Mariaha Ray 5: Sam Riegel Is there common members? Is there common members now? LEL false Phase 3: Class Game Create class Game, which is a Laser Taggame between two teams. To accomplish this: Add constructor that has 2 Team parameters, one for each team that is participating in this game Add method public boolean validGanc() that checks to see if these two teams can participate in a game Teams can play each other if. There are no members that are perticipants in both tears, and both teams are ful no more members can be added). public void awardwinner (Teak winner, int points), which gives points to the team members of the winning team. Points are divided equally between the team members. Round down the points do not divide evenly to the number of players. To do this, you may add methods to the Game class. Consider where the code for this task should exist for maximum cohesion in your objects Teams that did not winget points awarded You may assume that winner will be passed a team that is part of this game AtoString method that prints the team rosters side-by-side. Print "Not a valid game if the game is not valid (as defined above). Otherwise, print the team rosters side-by-side. The right column must be alige properly. Example Team rosters: Ashley Johnson Chris Straub Laura Bailey Amy Falcone Liam O'Brien Kate Welch Sa Riegel Ryan Hartman Talicoin Jatte Jerry Holking Phase 4: Class Location Games happen at Laser Tag locations. Create a Location class that represents a location where Laser Tag games happen Locations have games, and members In your Location class tracks a list of members (use a partially-filled array) Add the following methods Constructor with two parameters: String name, String address, which are stored for use in the toString method public void addMember(Player newbie) which adds a member to the membership list that is tracked by this object. publie string tostring() which prints the name and address of the location, then prints out al the names, number of games played, and average score of all the players that belong to this Laser Tag location. Consider any methods you have already written to help you do this Sample output Membership list for Laser Topia, Waverley Ave location Player: Player: Jerry Holkins has played 1 game with an average of 20 Player: Travis Willingham has played no games A so, add a second constructor to class Player, which accepts 2 parameters: String name, Location place. When givena Location, the constructor the Player becomes a member of the given Location Finally, add static data and methods to Location: A partially filled array, that tracks all of the locations public static String all Location Names which returns a String of all the location names public static String which Locations Player who, which returns a string of all the Locations that the Player who is a member ol. Sample outout Orion Amaha is a member at Darkzone Lasertopia Instructions You must complete the "Blanket Honesty Declaration checklist on the course website before you can submit any assignment. You will not be able to see the dropbox if you have not accepted the Honesty Declaration Only submit the java files. Do not submit any other files, unless otherwise instructed To submit the assignment, upload the specified files to the Assignment 1 folder on the course website. Assignments must follow the programming standards document published on UMLearn. After the due date and time, assignments may be submitted but will be subject to a late penalty. Please see the ROASS document published on UMLearn for the course policy for late submissions If you make multiple submissions, only the most recent version will be marked. These assignments are your chance to learn the material for the exams. Code your assignments independently. We use software to compare all submitted assignments to each other, and pursue academic dishonesty vigorously Your Java programs must compile and run upon download, without requiring any modifications Assignment overview In this assignment, you will implement a set of related classes of objects: Player: A Laser Tag player Team: A team of Laser Tag players Game: A game of Laser Tag between two teams Location: A Laser Tag venue, which players can be members of Keep all of your methods short and simple. In a properly-written object-oriented program, the work is distributed among many small methods, which call cach other. There are no methods in this entire assignment that should require more than 10 lines of code, not counting comments, blank lines, or lines (and many of them need no more than 3). Unless specified otherwise, all Instance variables must be private, and all methods should be public. Also, unless specified otherwise, there should be no printin statements in your classes. Objects usually do not print anything, they only return String values from toString methods Your code should be DRY- don't repeat yourself. If you have a method that already accomplishes a task, or has some logic, that logic should be used. You may add any private methods you see fit to help accomplish this task. The description of the assignment has methods that are required. There are suggested names for the parameters, which you may change. Do not change the signatures of the methods. Your classes and objects should work with the pravided test files You may not use an ArrayList in this assignment. You may write your own collection class, but that is not the expectation for this assignment. Testing Your Coding We have provided sample test files for each phase to help you see if your code is working according to the assignment specifications. These files are starting points for testing your code Part of developing your skills as a programmer is to think through additional important test cases and to write your own code to test these cases. Different, more vigorous tests will be used to test your program. Sample output is provided in some cases, for you to match as closely as possible. Other output is left out, for you to practice reading code, understand a program, and practice seeing it output is correct or not based on inputs. Phase 1: Class Player This class represents a Laser Tag player in our system. The class tracks the user's name, how many games they have played, and can calculate their average score. You will need to make instance varables to keep this information in your objects Class player requires the following methods: A constructor public Player(String nane). Initialize other instance variables as required Methed public void addGameResult(int newscore). This method is called after a game is played, the value passed is added to the user's average that is being bracked by this object public boolean equals(Player other), which checks equality of two Player objects. TWO Player Objects are equalif the names of the two Players are the same A tostring method that prints out information of the object of the player has not played any Eames print that the player has not played any games. If they player has played some games, print out the player's game average score. Use integer division to calculate the average. See the sample output, and match it as closely as possible. Accessor method gmt.Name(), which runs the player's name Sample output: Should print "Players Jim Beam has played no games Player: Jim Beam tas played no games Should print "Player: Johnny Walker has played no games" Player: Johnny Walker has played no games Should print "Player: Jim Beam has played i game with an average of SO" Player Jim Beam has played i game with an average of 50 Should print "Player: Jim Beam has played 2 games with an average of 52 Player: Jim Beam las played 2 games with an average of 51 Should print "Player: Johnny Walker has played 50 games with an average of 25 Player: Johnny Walker has played 50 games with an average of 25 true false Hello, my name is Jim Beam Phase 2: Class Team Create class Team, which is a collection of players who play Laser Tag games. Teams have maximum sizes and players that come and go from the team. Use a partially-filled array to keep track of the players on the team. - Create a constant to track the maximum size of the team Set the constant to 5 Add a constructor, that has no parameters, if you need are Add method public boolean addMember(Player nene), which adds a player to the team A player can be added to a team : the player is not already or the team and there is space left in the team. Players can be a part of more than one tean. Add method public String costring(), which prints out the team roster. See sample output for the format required. Add method public boolean hasCommon Players (Team other), which returns true if there is a player that is on the roster of both teams Methed public boolean teampull(), which returns true if the team has a full complement of members. Use the constant you used for maximum size of the team to determine this Method public boolean remove Player(Player toRemove), which removes a player from the team. Method public player getRosterl) which returns a deep copy of the team. The returned array should be the same sees the number of players. For instance, if there is only 1 member on the team, the returned array should return an array of size 1. You do not have to do a recursive deep copy, that is you do not have to deep copy the Player objects - just the array Sample output: Teams 1: Ashley Johnson Teens 1. Ashley Johnson 2: Laura Bailey Tember: 1. Ashley Johnson 2: Laura Bailey Team members: 1: Ashley Johnson 2. Laura Bailey 3: Liam O'Brien 4: Narisha Ray false Team members: 1: Ashley Johnson 21 Laura Bailey 3: Lla. O'Brien 4: Maripa Ray 5: Riegel LE true Team members: 1. Ashley Johnson 2: Laura Bailey 3: Liam O Brien 4: Mariaha Ray 5: Sam Riegel Is there common members? Is there common members now? LEL false Phase 3: Class Game Create class Game, which is a Laser Taggame between two teams. To accomplish this: Add constructor that has 2 Team parameters, one for each team that is participating in this game Add method public boolean validGanc() that checks to see if these two teams can participate in a game Teams can play each other if. There are no members that are perticipants in both tears, and both teams are ful no more members can be added). public void awardwinner (Teak winner, int points), which gives points to the team members of the winning team. Points are divided equally between the team members. Round down the points do not divide evenly to the number of players. To do this, you may add methods to the Game class. Consider where the code for this task should exist for maximum cohesion in your objects Teams that did not winget points awarded You may assume that winner will be passed a team that is part of this game AtoString method that prints the team rosters side-by-side. Print "Not a valid game if the game is not valid (as defined above). Otherwise, print the team rosters side-by-side. The right column must be alige properly. Example Team rosters: Ashley Johnson Chris Straub Laura Bailey Amy Falcone Liam O'Brien Kate Welch Sa Riegel Ryan Hartman Talicoin Jatte Jerry Holking Phase 4: Class Location Games happen at Laser Tag locations. Create a Location class that represents a location where Laser Tag games happen Locations have games, and members In your Location class tracks a list of members (use a partially-filled array) Add the following methods Constructor with two parameters: String name, String address, which are stored for use in the toString method public void addMember(Player newbie) which adds a member to the membership list that is tracked by this object. publie string tostring() which prints the name and address of the location, then prints out al the names, number of games played, and average score of all the players that belong to this Laser Tag location. Consider any methods you have already written to help you do this Sample output Membership list for Laser Topia, Waverley Ave location Player: Player: Jerry Holkins has played 1 game with an average of 20 Player: Travis Willingham has played no games A so, add a second constructor to class Player, which accepts 2 parameters: String name, Location place. When givena Location, the constructor the Player becomes a member of the given Location Finally, add static data and methods to Location: A partially filled array, that tracks all of the locations public static String all Location Names which returns a String of all the location names public static String which Locations Player who, which returns a string of all the Locations that the Player who is a member ol. Sample outout Orion Amaha is a member at Darkzone Lasertopia

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

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions