PageRenderTime 61ms CodeModel.GetById 58ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/examples/restbuck_server/src/domain/item.e

http://github.com/jocelyn/EiffelWebReloaded
Specman e | 79 lines | 63 code | 13 blank | 3 comment | 1 complexity | 74f4567ac8485365cfb97081e50d4c32 MD5 | raw file
 1note
 2	description: "Summary description for {ITEM}."
 3	author: ""
 4	date: "$Date$"
 5	revision: "$Revision$"
 6
 7class
 8	ITEM
 9inherit
10	ITEM_CONSTANTS
11create
12	make
13feature -- Initialization
14	make ( a_name : STRING_32 ; a_size:STRING_32; a_option: STRING_32; a_quantity:INTEGER_8)
15		do
16			set_name (a_name)
17			set_size (a_size)
18			set_option (a_option)
19			set_quantity (a_quantity)
20		end
21
22feature -- Access
23	name : STRING
24		-- product name type of Coffee(Late, Cappuccino, Expresso)
25
26	option : STRING
27		-- customization option Milk (skim, semi, whole)
28
29	size : STRING
30		-- small, mediumm large
31
32	quantity :INTEGER
33
34
35
36
37feature -- Element Change
38	set_name (a_name: STRING)
39		require
40			valid_name: is_valid_coffee_type (a_name)
41		do
42			name := a_name
43		ensure
44			name_assigned : name.same_string(a_name)
45		end
46
47	set_size (a_size: STRING)
48		require
49			valid_size : is_valid_size_option (a_size)
50		do
51			size := a_size
52		ensure
53			size_assigned : size.same_string(a_size)
54		end
55
56	set_option (an_option: STRING)
57		require
58			valid_option : is_valid_milk_type (an_option)
59		do
60			option := an_option
61		ensure
62			option_assigned : option.same_string (an_option)
63		end
64
65	set_quantity (a_quantity: INTEGER)
66		require
67			valid_quantity : a_quantity > 0
68		do
69			quantity := a_quantity
70		ensure
71			quantity_assigned : quantity = a_quantity
72		end
73
74invariant
75		valid_size : is_valid_size_option (size)
76		valid_coffe : is_valid_coffee_type (name)
77		valid_customization : is_valid_milk_type (option)
78		valid_quantity :   quantity > 0
79end