• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 8. Objects > EXERCISES

EXERCISES

1:Create a circle object and a method that will calculate its circumference.
2:Write a function that will create a clock object.
  1. It will have three properties: seconds, minutes, and hours.

  2. Write two methods: setTime() to set the current time and displayTime() to display the time.

  3. The user will be prompted to select either a.m., p.m., or military time. The value he chooses will be passed as an argument to the display() method.

  4. The output will be either

    14:10:26 or 2:10:26

    depending on what argument was passed to the display() method.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint