Question: JAVA ILLUMINATED An Active Learning Approach. QUESTIONS. CHAPTER 7.18.6 61. Write a class encapsulating the concept of a corporate name (for example, IBM), assuming a

JAVA ILLUMINATED An Active Learning Approach.

QUESTIONS.

CHAPTER 7.18.6

61. Write a class encapsulating the concept of a corporate name (for example, IBM), assuming a corporate name has only one attribute: the corporate name itself. Include a constructor, the accessors and mutators, and methods toString and equals. Also include a method returning a potential domain name by adding www. at the beginning and .com at the end of the corporate name (for instance, if the corporate name is IBM, that method should return www.ibm.com). Write a client class to test all the methods in your class.

public class CorporateNameClient { public static void main( String [] args ) { CorporateName cn1 = new CorporateName( "IBM" ); CorporateName cn2 = new CorporateName( "AMD" ); System.out.println( "The name of corporate name #1 is " + cn1.getName( ) ); System.out.println( "Corporate name #2 is " + cn2.toString( ) ); System.out.println( "A suggested domain name is " + cn2.domainName( ) );

if ( cn1.equals( cn2 ) ) System.out.println( "Original corporate names #1 and #2 are identical" ); else System.out.println( "Original corporate names #1 and #2 are different" );

cn2.setName( "IBM" );

if ( cn1.equals( cn2 ) ) System.out.println( "Original corporate name #1 and modified corporate name #2 are identical" ); else System.out.println( "Original corporate name #1 and modified corporate name #2 are different" );

} }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!