Problem

Visit www.myprogramminglab.com to complete select exercises online and get instant feedbac...

Visit www.myprogramminglab.com to complete select exercises online and get instant feedback.

Exercise

Use the Model-View-Controller pattern to implement a simple timer-based counter. The counter should start at a user-specified initial value and increment by one every second until it reaches a user-specified final value. A UML diagram depicting the three classes for the pattern is shown below. The word “in” means the parameter is used to deliver data to the method.

The Counterview class should simply take an input counter value and print it on the console screen.

The CounterModel class should have a variable that represents the counter’s value. The Increment method increments the counter by one and calls Counterview’s Display method.

The CounterController class takes a start and end value that is specified by the user. CounterModel is then initialized with the start value. When the Start method is invoked, it calls CounterModel’s increment method once per second until endValue -startValue seconds have elapsed.

You will need to implement additional variables or methods in addition to those shown above in order to create the linkages between classes.

You can use the method call Thread.sleep(10 00) to make the CounterController wait for one second. The call must be placed inside a try/catch block.

Test your program with a main method that counts several different ranges of values.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 12