simple_mtglife
diff mainwin.cc @ 4:7cac97dca573
added coin flip
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 26 Jan 2015 07:48:56 +0200 |
parents | d76fb2ffe7f5 |
children |
line diff
1.1 --- a/mainwin.cc Mon Jan 26 06:03:12 2015 +0200 1.2 +++ b/mainwin.cc Mon Jan 26 07:48:56 2015 +0200 1.3 @@ -1,3 +1,4 @@ 1.4 +#include <random> 1.5 #include <QMessageBox> 1.6 #include "mainwin.h" 1.7 #include "ui_mainwin.h" 1.8 @@ -69,3 +70,17 @@ 1.9 "GNU General Public License version 3 (or any later version)."; 1.10 QMessageBox::about(this, "About simple_mtglife", about_text); 1.11 } 1.12 + 1.13 +void MainWin::on_action_flip_coin_triggered() 1.14 +{ 1.15 + static std::mt19937 gen; 1.16 + static std::bernoulli_distribution distr(0.5); 1.17 + bool res = distr(gen); 1.18 + 1.19 + QMessageBox msg; 1.20 + msg.setText(res ? "<big>heads!</big>" : "<big>tails!</big>"); 1.21 + msg.setIconPixmap(QPixmap(res ? ":data/mtg_heads.png" : ":data/mtg_tails.png")); 1.22 + msg.setWindowTitle("Coin flip"); 1.23 + msg.setModal(true); 1.24 + msg.exec(); 1.25 +}