Question: JAVA ILLUMINATED An Active Learning Approach. QUESTIONS. CHAPTER 7.18.6 60. Write a class encapsulating the concept of website statistics, assuming website statistics have the following

JAVA ILLUMINATED An Active Learning Approach.

QUESTIONS.

CHAPTER 7.18.6

60. Write a class encapsulating the concept of website statistics, assuming website statistics have the following attributes: number of visitors and type of site (commercial, government, etc.). Include a constructor, the accessor and mutators, and methods toString and equals. Write a client class to test all the methods in your class.

public class WebSiteStatsClient { public static void main( String [] args ) { WebSiteStats wss1 = new WebSiteStats( 12804, "government" ); WebSiteStats wss2 = new WebSiteStats( 45009, "commercial" ); System.out.println( "The visitors of web site stats #1 is " + wss1.getVisitors( ) ); System.out.println( "The type of web site stats #1 is " + wss1.getType( ) ); System.out.println( "Web Site Stats #2 is " + wss2.toString( ) );

if ( wss1.equals( wss2 ) ) System.out.println( "Original web site stats #1 and #2 are identical" ); else System.out.println( "Original web site stats #1 and #2 are different" );

wss2.setVisitors( 12804 ); wss2.setType( "government" ); if ( wss1.equals( wss2 ) ) System.out.println( "Original web site stats #1 and modified web site stats #2 are identical" ); else System.out.println( "Original web site stats #1 and modified web site stats #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!