i missed lecture today and this is what they did in class. im not sure how to complete this. hope you all can help me out.

class Clock
{
// Declare fields of the class
// 0 <= hours < 24, 0 <= minutes < 60, 0 <= seconds < 60
private int hours, minutes, seconds;
Clock(int hh, int mm, int ss) //constructor
{
}
//increase time by sec seconds
public void incrementSeconds(int sec)
{
}
//increase time by min minutes
public void incrementMinutes(int min)
{
}
//increase time by hh hours,
//if hours reach 24, simply wrap around to 0.
public void incrementHours(int hh)
{
}
public void addTime(Clock C) //add C into the clock
{
}
//print time in hours:minutes:seconds am(or pm) format
public void printTime()
{
}
}
class ClockDemo
{
public static void main(String [] args)
{
//write each statement for each operation below
(create Clock object C1 with h:m:s = 0:0:0)
(create second Clock object C2 with h:m:s=12:35:59)
(add C2 into C1)
(print C1)
(print C2)
(increase clock C1 by 1 seconds)
(print C1)
(increase clock C1 by 100 minutes)
(print C1)
(increase clock C1 by 10 hours)
(print C1)
(print C2)
}
}

So "what they did in class" was to assign a lot of blank methods that you are supposed to implement. You would've heard the teacher's spiel about doing your own work, too, except you weren't there for that either. My point here is this: do your own work. We're here to help people learn, not to do people's work. Oh, and btw: you also didn't follow the forum rules by posting code tags, and you also did not ask any questions.

ive heard the spiel of doing my own work, copying code is the same as plagiarism. im not asking anyone to completely solve this and give me the code... i dont understand what this is even asking. looking at that it doesnt make any since to me.

i missed lecture today and this is what they did in class. im not sure how to complete this. hope you all can help me out.

My guess is that you missed the lecture because you were held over in Engrish?

This is your assignment:

Complete the Clock class. You have been supplied with a nice template for which (as mentioned above in another response) you need to supply the implementation code for the mutator and accessor methods. You only have 3 states to mess with, so it should not take a lot of effort.

In addition, you need to complete the ClockDemo class which will demonstrate the following:

1. Creating 2 different instances of the class Clock.
(create Clock object C1 with h:m:s = 0:0:0)
(create second Clock object C2 with h:m:s=12:35:59)

2. Adding the value of the second class to the first and printing both using the printTime() method.
(add C2 into C1)
(print C1)
(print C2)

3. Modifying the first instance values 3 different times, printing the result after each modification.
(increase clock C1 by 1 seconds)
(print C1)
(increase clock C1 by 100 minutes)
(print C1)
(increase clock C1 by 10 hours)
(print C1)

4. Just for kicks, calling the printTime() method of the second object one more time.
(print C2)

Hopefully this provides the clarity you were asking for.

yes thanks, that helps me understand it a little better. im still not really figuring out how to call the functions properly but i guess ill just mess with it a little more and see what i can do.

yes thanks, that helps me understand it a little better. im still not really figuring out how to call the functions properly but i guess ill just mess with it a little more and see what i can do.

Here is a resource that you can look at for an example of how to create your implementations of your Clock class, and how to call the methods (functions) of it.

http://www.javacoffeebreak.com/java102/java102.html

It will most certainly help you to understand classes enough for your assignment. Read the entire document, and study the design of the class 'Account' structure. It has a similar type of structure to your clock Class, with some hints in it as to how you would deal with modifying your states (variables) in the class. It also contains examples of creating objects and how to call the methods of the instance.

FYI in the link that Patrick gave you, the ideas are good so far as I've seen, but the syntax would not compile. You cannot create a new 'Account' Object by saying account myaccount = new account(). You must say Account account = new Account(); (or whatever the constructor is). Java is case sensitive. And these are the "official" Java tutorials on class, objects, etc and they are excellent. So if you get through the tutorial Patrick gave you and still don't get it, try out the java sun one.

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.