Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Constructor for a clock

808151Nov 18 2010 — edited Nov 19 2010
So in my assignment I gotta make a whole class with constructors and such.
I've spent a good while reading my book on the topic and trying a variety of things but I can't figure out how to obtain the output I need.
Here's the different codes:

First this is my ClockClient.java file (that contains the main):
import java.util.Random;

public class Assignment4a
{
public static void main(String[] args)
{
Random rand = new Random(47); // Set the seed of this random number generator to 47
System.out.println("\nTesting constructors\n");
Clock c1 = new Clock();
Then this is the Clock.java class
public class Clock {

	
	public Clock() {
	
        // This is where i cannot help for the life of myself find what I gotta write
        // to get the desired output, which you can see in the next code quoted box below

		
	}
This is the desired output according to my PDF file that shows me what it should do.
Testing constructors
C1 00:00:00
So far this is what it prints out for me if I run it:
Testing constructors

C1 Clock@62f72617
Obviously this is because I wrote nothing in it, but whatever I try to write in it I get no results or some funky outcomes. Any help? Google, and my 1200 page java book couldn't help me ;_;
Thanks in advance.

Edited by: Darryl Burke -- broke a long comment in two lines
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 17 2010
Added on Nov 18 2010
6 comments
290 views