代码拉取完成,页面将自动刷新
/* 点击一个‘猫叫’按钮,弹出‘喵’的提示框 */
#pragma execution_character_set("utf-8")
#include "Widget.h"
#include "ui_widget.h"
#include <QMessageBox>
#include "Cat.h"
#include "Dog.h"
#include "Cattle.h"
#include "Sheep.h"
#include "MachineCat.h"
#include "StoneMonkey.h"
#include "IChange.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
setWindowTitle("动物运动会");
}
void Widget::on_catBtn_clicked()
{
Cat cat("小咪");
cat.setShoutNum(5);
QMessageBox::information(this, " ", cat.Shout());
}
void Widget::on_dogBtn_clicked()
{
Dog dog("旺财");
dog.setShoutNum(5);
QMessageBox::information(this, " ", dog.Shout());
}
void Widget::on_animalRegistBtn_clicked()
{
animalList.append(new Cat("小花"));
animalList.append(new Dog("阿毛"));
animalList.append(new Cattle("小黑"));
animalList.append(new Sheep("娇娇"));
animalList.append(new Cat("咪咪"));
animalList.removeAt(1);
animalList.removeAt(1);
}
void Widget::on_shoutCompareBtn_clicked()
{
for (int i = 0; i < animalList.count(); i++) {
QMessageBox::information(this, " ", animalList[i]->Shout());
}
}
Widget::~Widget()
{
delete ui;
}
void Widget::on_changeBtn_clicked()
{
MachineCat mcat("小叮当");
StoneMonkey wukong("孙悟空");
QList<IChange*> array;
array.append(&mcat);
array.append(&wukong);
QMessageBox::information(this, " ", array[0]->ChangeThing("各种各样的东西!"));
QMessageBox::information(this, " ", array[1]->ChangeThing("各种各样的东西!"));
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。