ok this is what the professor want us to do:
Description
There are two data files you’ll need to build your league; Teams.txt and Players.txt. Teams.txt contains the names of the teams in your league while Players.txt has one line of data for each player. Here are excerpts from the two files:
Teams.txt
Diamondbacks
Braves
Cubs
...
Giants
Cardinals
Nationals
Players.txt
Diamondbacks Aquino Greg 325000 Pitcher
Diamondbacks Bruney Brian 322500 Pitcher
Diamondbacks Cintron Alex 360000 Shortstop
Diamondbacks Clayton Royce 1350000 Shortstop
Diamondbacks Counsell Craig 1350000 Second Baseman
Diamondbacks Cruz Jose 4000000 Outfielder
Diamondbacks Estes Shawn 2500000 Pitcher
...
Nationals Sledge Terrmel 345000 Outfielder
Nationals Tucker TJ 657000 Pitcher
Nationals Vargas Claudio 325000 Pitcher
Nationals Vidro Jose 7000000 Second Baseman
Nationals Wilkerson Brad 3050000 Outfielder
1. Player and Team Classes
Your Player should have a name, position and salary, along with the appropriate get/set methods and a toString() method.
Your Team class should have a team name and an ArrayList of players. You’ll also need to add a couple of methods to your Team class.
- a method to add players to your Team
- a method to retrieve the highest paid player on your team by position
Player getHighPay(“Pitcher”)
- a method that returns the cumulative payroll for your team
int getPayroll()
- you should add other methods as you see necessary
2. League Class
Define a League class that has a league name and an ArrayList of Teams. Here are a few methods you may want for your League. You should add others as you see necessary:
- void createTeams(): reads the Teams.txt data file, instantiates a team object for each team name in the file and adds it to the array list of teams.
- void populateTeams(): reads the Players.txt data file, instantiates a player object for each player in the file and adds it to the correct team.
- void openFiles(): opens the data files
- void closeFiles(): closes the data files
- void outputToFile(ArrayList<Player> list): outputs the contents of the ArrayList to a file.
- ArrayList<Player> getHighPaidInfield(String teamName): for the given team, return an ArrayList with the highest paid infielders. In other words, the highest paid pitcher on the team, catcher, first baseman, second baseman, third baseman and shortstop. Hint: You might want to think about calling the getHighPay() method that you have already written multiple times.
- void displayTeam(String teamName): displays all players on the roster to the console.
- Team getHighPayrollTeam(): returns the team with the highest overall payroll in the league.
3. Testing your classes
Add a main method to your League class or create a separate class with a main method. Use the following to test your classes:
League national = new League("National");
national.displayTeam("Cardinals");
ArrayList<Player> infield = national.getHighPaidInfield("Dodgers");
national.outputToFile(infield);
Team t = national.getHighPayrollTeam();
System.out.println("Highest paid team is the " + t.getName() +
" with a payroll of " + t.getPayroll());
4. Checking your results
Using the given data file, the highest paid team is the Mets. They had a payroll of 101,305,821.
The highest paid infield on the Dodgers roster consists of:
Pitcher: Darren Dreifort
Catcher: Paul Bako
First Baseman: Olmedo Saenz
Second Base: Jeff Kent
Third Baseman: Jason Grabowski
Shortstop: Jose Valentin
so far i can do easily the first part i mean the player class which i will show you right now so this is my player class
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package HomeWork06; import java.io.*; import java.util.*; /** * * @author ElvisBoss */ public class Player { private String Name; private String Position; private int Salary; public Player(){ } public String getName() { return Name; } public String getPosition() { return Position; } public int Salary() { return Salary; } public String toString() { return "Player Name = " + Name + " Player Position = " + Position + " Player Salary = " + Salary; } }
the second class that is Team class i start with this but i do not think it is right
so that one is easy now the other 2 i am completely lost please HELP i will really appreciate it... THANK YOU/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package HomeWork06; /** * * @author ElvisBoss */ import java.io.*; import java.util.*; public class Team { private String TeamName; ArrayList playerList = new ArrayList(); public void addPlayers() { } public String getHighPay(String Position) { return Position; } public int getPayroll() { return Total; } }