Use the model-view-controller pattern to implement a simple


Question: 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.

2085_15.png

- The Counter View class should simply take an input counter value and print it on the console screen. The Counter Model class should have a variable that represents the counter's value. The Increment method increments the counter by one and calls Counter View's Display method.

- The Counter Controller class takes a start and end value that is specified by the user. Counter Model is then initialized with the start value. When the Start method is invoked, it calls Counter Model‘s increment method once per second until end Value - start Value 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 (1000) to make the Counter Controller 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.

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Use the model-view-controller pattern to implement a simple
Reference No:- TGS02404854

Now Priced at $10 (50% Discount)

Recommended (92%)

Rated (4.4/5)