Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Varuna Seneviratna
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • 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


 
Brian Legg
Ranch Hand
Posts: 488
  • Mark post as helpful
  • send pies
  • 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.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50211
79
  • Mark post as helpful
  • send pies
  • 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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic