File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes I would like to have your advice about the way I have designed the application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "I would like to have your advice about the way I have designed the application" Watch "I would like to have your advice about the way I have designed the application" New topic
Author

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

Varuna Seneviratna
Ranch Hand

Joined: Jan 15, 2007
Posts: 167
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



Varuna Seneviratna
Brian Legg
Ranch Hand

Joined: Nov 07, 2008
Posts: 488
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.


SCJA
~Currently preparing for SCJP6
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
Are you sure you need Hour and Minute classes? Can you use Display classes with maximum (hour = 23, minute = 59) fields instead?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I would like to have your advice about the way I have designed the application