Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA QUESTION. 58. Write a class encapsulating the concept of a course, assuming a course has the following attributes: a code (for instance, CSI), a

JAVA QUESTION.

58. Write a class encapsulating the concept of a course, assuming a course has the following attributes: a code (for instance, CSI), a description, and a number of credits ( for instance, 3). 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 CourseClient { public static void main( String [] args ) { Course c1 = new Course( "CS1", "Intro to Computer Science", 4 ); Course c2 = new Course( "CS2", "Intro to Data Structures", 3 ); System.out.println( "The code of course # 1 is " + c1.getCode( ) ); System.out.println( "The description of course # 1 is " + c1.getDescription( ) ); System.out.println( "The number of credits of course # 1 is " + c1.getCredits( ) ); System.out.println( "Course # 2 is " + c2.toString( ) );

if ( c1.equals( c2 ) ) System.out.println( "Original courses #1 and #2 are identical" ); else System.out.println( "Original courses #1 and #2 are different" );

c2.setCode( "CS1" ); c2.setDescription( "Intro to Computer Science" ); c2.setCredits( 4 );

if ( c1.equals( c2 ) ) System.out.println( "Original course #1 and modified course #2 are identical" ); else System.out.println( "Original course #1 and modified course #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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Database And Expert Systems Applications 31st International Conference Dexa 2020 Bratislava Slovakia September 14 17 2020 Proceedings Part 1 Lncs 12391

Authors: Sven Hartmann ,Josef Kung ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

303059002X, 978-3030590024

More Books

Students also viewed these Databases questions

Question

2-5 How will MIS help my career?

Answered: 1 week ago

Question

Azure Analytics is a suite made up of which three tools?

Answered: 1 week ago

Question

Explain how to build high-performance service delivery teams.

Answered: 1 week ago