lucky draw

lucky draw preview image

1 collaborator

Default-person Brian Chih (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.4.0 • Viewed 8 times • Downloaded 0 times • Run 0 times
Download the 'lucky draw' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

globals [tickets winners]

to setup

  clear-all

  set tickets [] ; 初始化籤的列表

  set winners [] ; 初始化中獎者號碼的列表

  let total-tickets number-of-tickets ; 從使用者那裡獲取總籤數

  ; 生成一個從1到total-tickets的數字列表

  repeat total-tickets [

    set tickets lput total-tickets tickets

    set total-tickets total-tickets - 1

  ]

  output-print (word "There are total " length tickets " lucky numbers.")
end 

to draw

  ifelse (length tickets > 0) [

    ; 隨機選擇一個籤並從列表中移除

    let drawn one-of tickets

    set tickets remove-item (position drawn tickets) tickets

    set winners lput drawn winners

    output-print (word "The lucky winner is: " drawn)

  ] [

    output-print "All the numbers are drawn."

  ]
end 



;to-report number-of-tickets
;
;  ; 這裡假設你有一個介面元素讓使用者輸入總籤數
;
;  report user-input "請輸入總共有多少個籤:"
;
;end

There is only one version of this model, created about 1 month ago by Brian Chih.

Attached files

File Type Description Last updated
lucky draw.png preview Preview for 'lucky draw' about 1 month ago, by Brian Chih Download

This model does not have any ancestors.

This model does not have any descendants.