
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Assignment 4 for cs121 computer programming i at pace university, due december 13, 2005. Students are required to create a java class named clock with private hour and minute instance variables, a public class variable nbrofclocks, constructors, accessors, and mutators. The testclock class is also to be created with a main method to test the clock class. The assignment includes instructions for formatting and submitting the completed source code.
Typology: Assignments
1 / 1
This page cannot be seen from the preview
Don't miss anything!
Assigned on December 1, 2005 Due on December 13, 2005
Write a program that a. Declares a class named Clock that i. maintains two private instance variables (instance data members) hour and minute of type int ; ii. maintains a public class variable (class data member) nbrOfClocks of type int , and initialize it to 0; at any time, this variable should tell us how many Clock objects have been created; iii. provides a constructor that can initialize the attributes hour and minute to values specified by the parameters; iv. provides an overloaded default constructor for initializing both hour and minute to zero; v. provides public accessors and mutators for attributes hour and minute ; vi. overloads method toString() so that the current time of a Clock object can be printed in a readable format. b. Declares a public class TestClock , and in its main() method, first creates a Clock instance c1 with the Clock ’s default constructor, and then creates a separate Clock object c2 with the first constructor and specifying the current time to be 10:15. Print both of the two Clock objects to verify that they contain the correct time. Print c1.nbrOfClocks , c2.nbrOfClocks , and Clock.nbrOfClocks to verify that they all print out value 2, the number of Clock objects that we have created.
The assignment is also posted in forum Assignments inside Discussion Board of CS121 Blackboard. Submit your completed source code file as an attachment to your reply to my assignment 4 thread.
Please add your name, your assignment completion date, and the above assignment problem description as comments at the beginning of your source code.
Please make sure that your program works correctly, and the source code is formatted properly with proper column alignment and line indentation. Add necessary concise comments to your tricky points for helping readers understand your program. There will be penalties for improper code alignment or indentation. Make sure that your program doesn’t contain lines longer than 80 characters so its printout doesn’t contain wrap-around lines.