On the further deepening of the last equivalence class test

Source: Internet
Author: User
Tags control characters

This week, I'm going to try to make further changes to the little program that I wrote last time for equivalence class testing, making it more complex and specific. The new requirement is to change the last input box to three input boxes.

and requirements for each number of boxes are satisfied:

Allow 1 to 6 English characters or numbers, press OK to end

First of all, the changes in the program is not too much, because I am using Java, first in the layout to make changes, add GridLayout, add two input text box. Second, in logical judgment,

There is not much change, nothing more than a synthesis of three boxes of input judgment results to make a final judgment, determine whether the input is legitimate

This is the part that makes a change to the layout of the interface

PrivateJButton sure =NewJButton ("OK"); PrivateJTextField input =NewJTextField (Ten); PrivateJTextField INPUT1 =NewJTextField (Ten); PrivateJTextField Input2 =NewJTextField (Ten); Hellow () {borderlayout borderlayout=NewBorderLayout (5,5);  This. setlayout (BorderLayout); GridLayout Grid=NewGridLayout (3,1); FlowLayout F1=NewFlowLayout (Flowlayout.center,Ten,Ten); FlowLayout F2=NewFlowLayout (Flowlayout.center,Ten,Ten); FlowLayout f3=NewFlowLayout (Flowlayout.center,Ten,Ten); JPanel P1=NewJPanel (F1); P1.add (NewJLabel ("NAME1:"));        P1.add (input); JPanel P2=NewJPanel (F2); P2.add (NewJLabel ("NAME2:"));        P2.add (INPUT1); JPanel P3=NewJPanel (F3); P3.add (NewJLabel ("NAME3:"));        P3.add (INPUT2); JPanel P4=NewJPanel (GRID);        P4.add (p1);        P4.add (p2);        P4.add (p3);        Add (P4, Borderlayout.center); JPanel Login_button=NewJPanel (NewFlowLayout (Flowlayout.right, -,                Ten));        Login_button.add (sure); Add (Login_button, Borderlayout.south);

Next, the code is as follows in logical judgment

intnum =input.gettext (). Length (); intNUM1 =input1.gettext (). Length (); intnum2 =input2.gettext (). Length (); if(num = =0|| num >6|| num1==0|| NUM1 >6|| num2==0|| Num2>6) {wronginput (); return; } String Temp=Input.gettext (); String Temp1=Input1.gettext (); String Temp2=Input2.gettext (); if(Temp.matches ("[0-9a-za-z]*") &&temp1.matches ("[0-9a-za-z]*") &&temp2.matches ("[0-9a-za-z]*") ) System. out. println ("OK"); Elsewronginput ();

First determine whether each input box satisfies the input word Fushun length between 1-6, otherwise directly prompt illegal, and then to each input box input content to judge, if there is a box

If the input is not valid, an illegal prompt is given, and if correct, the output is OK.

  valid class invalid class
first line input box character length length is 1-6 empty string
    length greater than 6
First line Input box character contents belongs to numbers, uppercase and lowercase control characters
    punctuation
second Line input box character length length 1-6 empty string
    length greater than 6
the second line of input box character contents is numeric, uppercase and lowercase control characters
    punctuation
Third line input box character length length 1-6 empty string
    length greater than 6
The third line of input box character contents is numeric, uppercase and lowercase control characters
    punctuation

Get test Cases

1. The first line AA1 2. The first line of empty string 3. AAAAAA1 4. First line aa1! 5. First line AA1 6. First line AA1

Second row Bb2 second row Bb2 second row Bb2 second row Bb2 second row empty string second row AaAaAa1

Third row Cc3 third row Cc3 third row Cc3 third row Cc3 third row Cc3 third row Cc3

7. The first line AA1 8. AA1 9. First line AA1 10. First row AA1

Second row bb2! Second row Bb2 second row Bb2 second row Bb2

Third row Cc1 third row empty string third row AaAaAa1 third row cc3!

On the further deepening of the last equivalence class test

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.