Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA QUESTION. 57. Write a class encapsulating the concept of a course grade, assuming a course grade has the following attributes: a course name and

JAVA QUESTION.

57. Write a class encapsulating the concept of a course grade, assuming a course grade has the following attributes: a course name and a letter grade. 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 CourseGradeClient { public static void main( String [] args ) { CourseGrade cg1 = new CourseGrade( "CS1", 'A' ); CourseGrade cg2 = new CourseGrade( "CS2", 'B' ); System.out.println( "The course of course grade #1 is " + cg1.getCourseName( ) ); System.out.println( "The grade of course grade #1 is " + cg1.getGrade( ) ); System.out.println( "Course Grade #2 is " + cg2.toString( ) );

if ( cg1.equals( cg2 ) ) System.out.println( "Original CourseGrade #1 and #2 are identical" ); else System.out.println( "Original CourseGrade #1 and #2 are different" );

cg2.setCourseName( "CS1" ); cg2.setGrade( 'A' );

if ( cg1.equals( cg2 ) ) System.out.println( "Original CourseGrade #1 and modified CourseGrade #2 are identical" ); else System.out.println( "Original CourseGrade #1 and modified CourseGrade #2 are different" );

} }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions