battle programminga forum for elite programmerswith extreme will powerto sharpen theire skills
 
HomeCalendarFAQSearchMemberlistUsergroupsRegisterLog in
Share
 

 java pauser class

Go down 
AuthorMessage
Moti Barski

Moti Barski

Posts : 293
Join date : 2011-08-02

java pauser class Empty
PostSubject: java pauser class   java pauser class EmptyTue Jan 22, 2019 10:13 pm

java pauser class 2s3mco

this class will be used to pause processes that run repeatedly.
it is very simple and very useful

Code:

public class Pauser {
 private int limit;
 private int counter;

 public int getLimit() {
 return limit;
 }

 public void setLimit(int limit) {
 this.limit = limit;
 }

 public Pauser(int limit) {
 super();
 this.limit = limit;
 this.counter = 0;
 }

 public Boolean pause() {
 if (counter == limit) {
 counter = 0;
 return false;
 } else {
 counter++;
 }
 return true;
 }
}

example :
Code:
Pauser p1 = new Pauser(2);
 System.out.println(p1.pause());
 System.out.println(p1.pause());
 System.out.println(p1.pause());
 System.out.println(p1.pause());
 System.out.println(p1.pause());
 System.out.println(p1.pause());
 System.out.println(p1.pause());
 System.out.println(p1.pause());
output :
true
true
false
true
true
false
true
true

hadouken ! :tu:

_________________
MB over and out _______________________     :trueogre:
Back to top Go down
View user profile
 
java pauser class
Back to top 
Page 1 of 1
 Similar topics
-
» Cannot locate the class Select in web driver
» How to compare images selenium, using java
» Selenium RC
» Retrieving number of rows in a table
» Selenium IDE to java with flow control

Permissions in this forum:You cannot reply to topics in this forum
battle programmers alliance :: battle programming alliance :: battle programming-
Jump to: