• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

I would like to have your advice about the way I have designed the application

 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Below is the source code and the description of a Digital Clock application I created, I would like to have your advice about the way I have designed the application, I was influenced by the Digital clock application in the Book Objects first with Java byDavid J Barnes and Michael Kolling.The Clock calss creates two objects of the Hour and Minute classes and both of which creates two objects of Display class.The Clock class calls methods of Hour and Minute classes as approproate and in turn the objects of Hour and Minute call on the methods of the two Display objects they created


PROJECT TITLE: Digital Clock
PURPOSE OF PROJECT: Simulate a Digital Clock
VERSION or DATE: 23-April-2009
HOW TO START THIS PROJECT: Create an object of Clock(Use BlueJ to execute the project)
AUTHORS: Varuna Seneviratna
USER INSTRUCTIONS: If you want to change the format of the time displayed change the
parameters of the constructor where creating the Display object
(in the constructors of Hour and Minute classes), which will decide the format of the time displayed



The source code Clock class



Hour class



Minute class



Display class


 
Ranch Hand
Posts: 488
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your code is object oriented, it's easy to read, and it works (I assume)... so I'd say congrats

I do think its overkill though... you could have written a program to do the exact same thing in less than 10 lines without the extra objects. Also, you never used the Date class... so it's not functional.

For a practice program though I like it... you've used a lot of different objects each which controls it's own properties

EDIT: On second thought, you would use the Calendar class... not the Date class which I had stated. Let me know if you'd like to see an example.
 
Marshal
Posts: 79240
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you sure you need Hour and Minute classes? Can you use Display classes with maximum (hour = 23, minute = 59) fields instead?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic