Member Avatar for THK

You are given a class named Clock that has one int instance variable called hours . Write a constructor for the class Clock that takes one parameter, an int , and gives its value to hours .

help me some one :(

Member Avatar for freesoft_2000

Hi everyone,

public class clock { public clock(int num) { } }

Richard West

Member Avatar for Rayhan Muktader

You need to give out more details. Do you wish learn how to write constructors in general or are having a particular problem with you Clock class?

Constructor for you Clock class would look something like the following code:

public Clock(int h)
{
this.hours = h;
}

Member Avatar for THK

thanks! it's been lot of help..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.