Question: JAVA QUESTION. 55. Write a class encapsulating the concept of a team (for example, Orioles), assuming a team has only one attribute: the team name.
JAVA QUESTION.
55. Write a class encapsulating the concept of a team (for example, Orioles), assuming a team has only one attribute: the team name. Include a constructor, the accessor and mutator, and methods toString and equals. Write a client class to test all the methods in your class. BELOW IS THE CLIENT AND I NEED A TEST CLASS!
public class TeamClient { public static void main( String [] args ) { Team t1 = new Team( "Orioles" ); Team t2 = new Team( "Yankees" ); System.out.println( "The name of team #1 is " + t1.getName( ) ); System.out.println( "Team #2: " + t2.toString( ) );
if ( t1.equals( t2 ) ) System.out.println( "Original teams #1 and #2 are identical" ); else System.out.println( "Original teams #1 and #2 are different" );
System.out.println( " Setting team #2 name to Orioles" ); t2.setName( "Orioles" );
if ( t1.equals( t2 ) ) System.out.println( "Original team #1 and modified team #2 are identical" ); else System.out.println( "Original team #1 and modified team #2 are different" );
} }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
