List Icon
Mailing list Archive

2019 up to July 2022 | 20182017  |  2016  2015 2014 | 2013

The mailing list has been closed since July 2022, but continues to serve as an archive of information about QF-Test.
If you want to stay informed about news about QF-Test, you can simply subscribe to our newsletter:
Subscribe to Newsletter  

 


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[QF-Test] Implementing Enum in scripting


  • Subject: [QF-Test] Implementing Enum in scripting
  • From: "Liu, Kevin (DPTI)" <Kevin.Liu@?.au>
  • Date: Thu, 13 Jul 2017 01:13:39 +0000
  • Delivered-to: qftest-list@?.net

Hi,

 

I am very new to QF-Test and Jython and Groovy scripting language, and I have a java class containing an Enum as follows:

 

public class CashDrawer {

 

private static enum Denomination {

                den02, den05, den5,den10;

 

                double getDenomValue(){

                                switch(this) {

                                                case den05:

                                                                return 0.5d;

                                                case den5:

                                                                return 5.0d;

                                                case den10:

                                                                return 10.0d;

                                                default:

                                                                return 0.2d;

                                }

                }

               

                //return the row number of the denomination in cash drawer table

                int getDenomRowNum() {

                                switch(this) {

                                                case den10:

                                                                return 1;

                                                case den5:

                                                                return 2;

                                                case den05:

                                                                return 3;

                                                default:

                                                                return 4;

                                }

                }

 

                Denomination getNextDenom() {

                                switch(this) {

                                                case den02:

                                                                return den05;

                                                case den05:

                                                                return den5;

                                                case den5:

                                                                return den10;

                                                default:

                                                                return null;

                                }

                }

 

               

}

 

private Denomination currentDenom;

 

.

.

.

}

 

And I also had a look at the class CheckDataType at section 41.4.4 in the manual, still haven’t got a clue on the implementation. Please give me some example on how to write the above Enum in Jython or Groovy SUT script.

 

Thanks in advance

Kevin