Blackshores C++ hörna
Hallå allihopa,
Tänkte att jag skulle lägga upp min C++ utveckling.
Är helt färsk på C++ har egentligen inte arbetat så mycket med programmering med en kompilerare inblandad tidigare.
Använder mig utav QT som IDE.
#1 - Tom Riddle's Diary
Mål: Lära sig att hantera strängar, söka i strängar och exekvera kommandon baserade på strängar.
Inspiration till detta är Tom Riddles dagbok som förekommer i en av Harry Potter böckerna, ett AI.
Kräver QT IDE för att kompilera
Diary.pro
QT += core testlib
QT -= gui
TARGET = DiaryString
CONFIG += console static
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
main.cpp
#include <QCoreApplication>
#include <iostream>
#include <string>
#include <QTest>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
std::string Present;
std::getline(std::cin, Present);
QTest::qSleep(3000);
std::system("cls");
QTest::qSleep(3000);
//searching for phrase
std::string search;
size_t pos;
search = "Harry Potter";
pos = Present.find(search);
if (pos != std::string::npos)
{
std::cout << "H l , " << search ;
QTest::qSleep(750);
std::system("cls");
std::cout << "Hel o, " << search ;
QTest::qSleep(750);
std::system("cls");
std::cout << "Hello, " << search ;
QTest::qSleep(3000);
std::cout << ", my" << std::endl << "name is Tom Riddle" << std::endl;
QTest::qSleep(8000);
std::system("cls");
}
else
std::cout << "I do not know you " << std::endl;
//stage 2
std::string Chambers;
std::getline(std::cin, Chambers);
QTest::qSleep(3000);
std::system("cls");
QTest::qSleep(3000);
std::string search2;
size_t pos2;
search2 = "Chambers of Secrets";
pos2 = Chambers.find(search2);
if (pos2 != std::string::npos)
{
std::cout << "Y .";
QTest::qSleep(500);
std::system("cls");
std::cout << "Yes";
QTest::qSleep(500);
std::system("cls");
}
else
std::cout << "You should ask about " << search2 << "." << std::endl;
//stage 3
std::string Tellme;
std::getline(std::cin, Tellme);
QTest::qSleep(3000);
std::system("cls");
QTest::qSleep(3000);
std::string search3;
size_t pos3;
search3 = "tell me";
pos3 = Tellme.find(search3);
if (pos3 != std::string::npos)
{
std::cout << " o.";
QTest::qSleep(300);
std::system("cls");
std::cout << "No.";
QTest::qSleep(700);
std::system("cls");
std::cout << "But I can show you";
QTest::qSleep(700);
std::system("cls");
std::cout << "Let me take you back" << std::endl << "fifty years ago" << std::endl;
QTest::qSleep(3000);
std::system("cls");
std::cout << " 13th of June" << std::endl;
}
else
std::cout << "You should ask about " << search3 << "." << std::endl;
return a.exec();
}