Em Andamento

Clock

Implement a 1000ms clock thread

Using the Observer/Observable classes create a number of listener objects that output the clock tick value each time the clock thread ticks

Interface [url removed, login to view] has one method -- update

Listener objects which implement Observer put their application logic in the update method body

Class [url removed, login to view] serves as a base class to objects which emit periodic events to Observers.

Invoke methods addObserver, and notifyObsevers in the base class to use the functionality

Beware the ‘hasChanged()’ side-effect of notifyObservers!

Question: How many threads are running in this exercise? Which objects run on which threads?

## Deliverables

Use the following code as a starting point.

import java.util.*;

class Main

{

public static void main (String[] args){

Clock clock;

int clockCycle, limit;

if ([url removed, login to view] != 2) {

[url removed, login to view]("usage: clockCycle limit");

[url removed, login to view](" clockCycle is the length, in milliseconds, of each clock tick");

[url removed, login to view](" limit is the number of clock ticks until all threads exit");

[url removed, login to view](" good values are 1000 for clockcycle, 10 for limit");

[url removed, login to view](-1);

}

clockCycle = new Integer(args[0]).intValue();

limit = new Integer(args[1]).intValue();

/* Create a new Clock object and a number of ClockWatchers

to watch it. Start the clock's thread.

*/

}

}

class Clock ???

{

}

class ClockWatcher ????

{

]

## Platform

Windows

Habilidades: Engenharia, Java, MySQL, PHP, Arquitetura de software, Teste de Software

Ver mais: system.err.println java, system err println, system err, java system err, err java, java thread, create java object, php exercise, string integer, java ticks string, base class events, code java exercise, threads java threads, logic question, methods events, clock interface, limit usage, time clock application windows, windows 2003 listener, time clock application, listener windows, clock clock, import method, watch object, public usage

Acerca do Empregador:
( 11 comentários ) United States

ID do Projeto: #3016118

Premiar a:

darkjava

See private message.

$2 USD em 3 dias
(1 Comentário)
0.0

2 freelancers estão ofertando em média $5 para este trabalho

ekkemu

See private message.

$8.5 USD in 3 dias
(6 Comentários)
2.1