SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Walter Savitch ,kenrick Mock
Chapter:
Uml And Patterns
Exercise:
Programming Projects
Question:4 | ISBN:9780132830317 | Edition: 5

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.











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(1000) 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.


TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Sorry the answer is not available at the moment…

If you are able to find the answer, please make sure to post it here. So that your Juniors have smile on their lips and feel happy.

Spread the 'tradition of sharing'.