This project is a Java-based application for managing and searching player data. The application allows users to search for players by various criteria, add new players, and save the data to a file.
- Clone the repository:
git clone https://github.com/gagradebnath/Project-L1-T2.git
- Navigate to the project directory:
cd Java_Term_Project_Part_1/finalProj - Compile the Java files:
javac -d bin src/*.java - Run the application:
java -cp bin Main
The application provides a menu-driven interface for interacting with the player database. The main menu options include:
- Search Players
- Search Clubs
- Add Player
- Exit System
You can search players by:
- Name
- Club and Country
- Position
- Salary Range
- Country-wise player count
You can search clubs by:
- Players with maximum salary
- Players with maximum age
- Players with maximum height
- Total yearly salary
You can add a new player by providing details such as name, country, age, height, club, position, number, and weekly salary.
Main.java: Contains the main class and the menu-driven interface.Player.java: Defines thePlayerclass with attributes and methods.PlayerDB.java: Manages the player database using various collections.FileIO.java: Handles reading from and writing to files.Searching.java: Provides methods for searching players based on different criteria.players.txt: Contains the initial player data.
The Main class contains the main method and the menu-driven interface for interacting with the application.
The Player class represents a player with attributes such as name, country, age, height, club, position, number, and weekly salary.
The PlayerDB class manages the player database using various collections such as maps and sets.
The FileIO class handles reading from and writing to files.
The Searching class provides methods for searching players based on different criteria.
main(String[] args): The main method that starts the application.showMenu(): Displays the main menu.searchPlayers(): Displays the player search menu.searchByClub(): Displays the club search menu.addPlayer(): Adds a new player to the database.print(Player p): Prints player details.printSet(Set<Player> set): Prints a set of players.
getName(): Returns the player's name.setName(String name): Sets the player's name.getCountry(): Returns the player's country.setCountry(String country): Sets the player's country.getAge(): Returns the player's age.setAge(int age): Sets the player's age.getHeight(): Returns the player's height.setHeight(double height): Sets the player's height.getClub(): Returns the player's club.setClub(String club): Sets the player's club.getPosition(): Returns the player's position.setPosition(String position): Sets the player's position.getNumber(): Returns the player's number.setNumber(int number): Sets the player's number.getWeeklySalary(): Returns the player's weekly salary.setWeeklySalary(int weeklySalary): Sets the player's weekly salary.toString(): Returns a string representation of the player.
addPlayer(Player p): Adds a player to the database.removePlayer(String name): Removes a player from the database.getPlayer(String name): Returns a player by name.getPlayersByClub(String club): Returns players by club.getPlayersByCountry(String country): Returns players by country.getPlayersByPosition(String position): Returns players by position.getPlayersBySalary(int salary): Returns players by salary.
readFile(String[] args): Reads player data from a file.saveData(): Saves player data to a file.
getPlayerByName(String name): Returns a player by name.getPlayerByClubAndCountry(String club, String country): Returns players by club and country.getPlayerByPosition(String position): Returns players by position.getPlayerBySalaryRange(int minSalary, int maxSalary): Returns players by salary range.countryWisePlayerCount(): Prints the country-wise player count.getPlayersWithMaxSalaryInClub(String club): Returns players with maximum salary in a club.getPlayersWithMaxAgeInClub(String club): Returns players with maximum age in a club.getPlayersWithMaxHeightInClub(String club): Returns players with maximum height in a club.getTotalSalaryInClub(String club): Returns the total yearly salary of a club.
Feel free to explore the code and modify it as per your requirements. Happy coding!