Player - System.out.print"Name" name =...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
// ********************************************************** // Player.java // // Defines a Player class that holds information about an athlete. // ********************************************************** import java.util.Scanner; public class Player { private String name; private String team; private int jerseyNumber; //----------------------------------------------------------- // Prompts for and reads in the player's name, team, and // jersey number. //----------------------------------------------------------- public void readPlayer() { Scanner scan = new Scanner(System.in);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: System.out.print("Name: "); name = scan.nextLine(); System.out.print("Team: "); team = scan.nextLine(); System.out.print("Jersey number: "); jerseyNumber = scan.nextInt(); } //-----------------------------------------------------------// Returns true if the given player is on the same team and has // the same jersey number as this player //-----------------------------------------------------------public boolean equals(Player p) { return team.equals(p.team) && jerseyNumber == p.jerseyNumber; } }...
View Full Document

This note was uploaded on 03/22/2010 for the course CS 202 taught by Professor Fong during the Spring '10 term at SIU Carbondale.

Ask a homework question - tutors are online