Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In JAVA, Implement the following UML for a counter that increments once a second

ID: 3935500 • Letter: I

Question

In JAVA,

Implement the following UML for a counter that increments once a second until a given number of seconds is reached. CounterModel -counter +CounterMode(in initialValue int) +Increment)void CounterView CounterController -startValue -endValue +Display(in int counterValue) +CounterController in int startValue, in int endValue) +Start() In this program, there will be 3 classes. Your test program will input a start and end number of seconds. Call the CounterController only from your test program. The controller will create an instance of CounterModel with the initial value and call increment until the end value is reached. The CounterModel will wait 1 second, increment its counter and then display its counter by calling CounterView. Use Thread.sleep (1000), to delay 1 second.+

Explanation / Answer

class countercontroller

{

int sv,ev,c;

System.out.println("This program tests timer");

DataInputStream in=new DataInputStream(System.in);

System.out.println("Enter start number of seconds");

sv=Integer.parseInt(in.readLine());

System.out.println("Enter end number of seconds");

ev=Integer.parseInt(in.readLine());

c=sv;

int countermode()

{

while(c<=ev;)

c=c+1;

try{

Thread.sleep(1000);

}

catch(Interrupted Exception e)

{

System.out.println("Thread Interrupted");

}

}

}

class counterview extends countercontroller

{

counterview(int sv,int ev,int c)

{

super(sv);

super(ev);

super(c);

}

int display()

{

for(c=sv;c<=ev;c++)

{

  System.out.println("Conter controller starting" +c);

}

}

}

class countermodel

{

public static void main(String args[])

{

int a,b,c;

string user input;

a=sv;

b=ev;

c1=a;

countercontroller c=new countercontroller();

c.countermode();

counterview v=new counterview(a,b,c1);

v.display();

System.out.println("Continue (y/n)");

userinput=in.readLine();

if(userinput=="y")

{

c.countercontroller();

v.display();

}

else{

  System.out.println("Process completed");

}

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote