Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package baseballmanager;
- import java.util.*;
- public class BaseballManager
- {
- public static final int MENU_ITEMS = 4;
- public String[] name = new String[25];
- public String[] position = new String[25];
- public int[] order = new int[25];
- public int count = 0;
- Scanner in = new Scanner(System.in);
- public static void main(String[] args)
- {
- BaseballManager baseballObject = new BaseballManager();
- }
- public BaseballManager()
- {
- while(true)
- {
- printMenu();
- boolean valid = false;
- int choice = 0;
- while(valid ==false)
- {
- choice = getChoice();
- if(choice > 0 && choice <= MENU_ITEMS)
- {
- valid = true;
- }
- else
- {
- System.out.println("Invalid Choice. Please pick 1-4.");
- }
- }
- makeChoice(choice);
- }
- }
- public void printMenu(){
- System.out.println("1. Display Line-up");
- System.out.println("2. Display Roster");
- System.out.println("3. Display Bench");
- System.out.println("4. Add Player");
- }
- public int getChoice()
- {
- in = new Scanner(System.in);
- System.out.print("> ");
- int choice = in.nextInt();
- return choice;
- }
- public void makeChoice(int choice)
- {
- switch(choice)
- {
- case 1: displayLineup();
- break;
- case 2: displayRoster();
- break;
- case 3: displayBench();
- break;
- case 4: addPlayer();
- break;
- }
- }
- public void displayLineup()
- {
- Arrays.sort(order);
- for(int a=0;a <order.length; a++)
- {
- {
- if(order[a] > 0)
- {
- System.out.println(name[0]);
- System.out.println(name[1]);
- }
- else
- {
- //Do nothing.
- }
- }
- }
- }
- public void displayRoster()
- {
- for(int b = 0; b < count; b++)
- {
- System.out.println(name[b]);
- }
- }
- public void displayBench()
- {
- for(int c=0;c <count; c++)
- {
- if(order[c] == 0)
- {
- System.out.println(name[c]);
- }
- else
- {
- //Do nothing.
- }
- }
- }
- public void addPlayer()
- {
- in = new Scanner(System.in);
- if(count < 25)
- {
- System.out.println("Enter Player Name: ");
- name[count] = in.nextLine();
- System.out.println("Enter Player Position: ");
- position[count] = in.nextLine();
- System.out.println("Enter Player Batting Order"
- + " (Enter 0 if not in batting lineup): ");
- order[count] = in.nextInt();
- count++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement