13.07.2015 Views

5 Model Programs

5 Model Programs

5 Model Programs

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

196 Testing Systems with Complex Stateusing System.Collections.Generic;using N<strong>Model</strong>;using N<strong>Model</strong>.Attributes;namespace Bag<strong>Model</strong>{static class Contract{static Bag content = Bag.EmptyBag;[Action]static void Add(string element){content = content.Add(element);}[Action]static void Delete(string element){content = content.Remove(element);}[Action]static int Lookup(string element){return content.CountItem(element);}}}[Action]static int Count(){return content.Count;}Figure 12.2. Bag model.possible input parameters is to provide a separate feature of the model that allowsonly a fixed set of elements to occur as input arguments to the respective actions.Such a feature is shown in Figure 12.3. This feature restricts the set of possibleelements to null, "", and "b". It uses the Domain attribute to associate a fixed set ofelements with each input parameter.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!