✨ Bunch of additions and changes
* added .pro.user to gitignore, added assignment no. 4.2, enhanced the mainwindow ui, removed the wrong .gitignore, enhanced the ExtendedVector READMEmain
parent
cfa6dc50ab
commit
69537f1367
@ -0,0 +1,52 @@
|
|||||||
|
#include <cctype> // for isdigit()
|
||||||
|
#include <cmath> // for pow()
|
||||||
|
#include <iostream>
|
||||||
|
#include <stack>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int convert(const string &s) {
|
||||||
|
string split_string = s;
|
||||||
|
stack<int> digits;
|
||||||
|
int conversion = 0;
|
||||||
|
auto it_s = s.begin();
|
||||||
|
|
||||||
|
for (;(*it_s == ' ') && (it_s != s.end()); it_s++); // skip all spaces
|
||||||
|
for (;(isdigit(*it_s)) && (it_s != s.end()); it_s++) {
|
||||||
|
digits.push((int) *it_s - (int) '0'); // put all decimal digits onto the stack
|
||||||
|
};
|
||||||
|
if(it_s == s.end() || *it_s == ' ') {
|
||||||
|
for (int i = 0; !(digits.empty()); i++) {
|
||||||
|
conversion += digits.top() * pow(10, i);
|
||||||
|
digits.pop();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// throw std::invalid_argument(s + " is not a correct int representation.");
|
||||||
|
// is what I'd like to do, but I guess I couldn't return -1 then, right?
|
||||||
|
cout << s + " is not a correct non-negative int representation." << endl;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return conversion;
|
||||||
|
}
|
||||||
|
|
||||||
|
void use_convert_function(const string &s) {
|
||||||
|
cout << s << " : " << convert(s) << endl << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_convert_function() {
|
||||||
|
use_convert_function("0");
|
||||||
|
use_convert_function("128");
|
||||||
|
use_convert_function("+128");
|
||||||
|
use_convert_function("12x128");
|
||||||
|
use_convert_function("128 + x");
|
||||||
|
use_convert_function("128 Punkte");
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
string s = "";
|
||||||
|
cout << "Please input a number: " << endl;
|
||||||
|
getline(cin, s);
|
||||||
|
use_convert_function(s);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@ -1,74 +0,0 @@
|
|||||||
# This file is used to ignore files which are generated
|
|
||||||
# ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
*~
|
|
||||||
*.autosave
|
|
||||||
*.a
|
|
||||||
*.core
|
|
||||||
*.moc
|
|
||||||
*.o
|
|
||||||
*.obj
|
|
||||||
*.orig
|
|
||||||
*.rej
|
|
||||||
*.so
|
|
||||||
*.so.*
|
|
||||||
*_pch.h.cpp
|
|
||||||
*_resource.rc
|
|
||||||
*.qm
|
|
||||||
.#*
|
|
||||||
*.*#
|
|
||||||
core
|
|
||||||
!core/
|
|
||||||
tags
|
|
||||||
.DS_Store
|
|
||||||
.directory
|
|
||||||
*.debug
|
|
||||||
Makefile*
|
|
||||||
*.prl
|
|
||||||
*.app
|
|
||||||
moc_*.cpp
|
|
||||||
ui_*.h
|
|
||||||
qrc_*.cpp
|
|
||||||
Thumbs.db
|
|
||||||
*.res
|
|
||||||
*.rc
|
|
||||||
/.qmake.cache
|
|
||||||
/.qmake.stash
|
|
||||||
|
|
||||||
# qtcreator generated files
|
|
||||||
*.pro.user*
|
|
||||||
CMakeLists.txt.user*
|
|
||||||
|
|
||||||
# xemacs temporary files
|
|
||||||
*.flc
|
|
||||||
|
|
||||||
# Vim temporary files
|
|
||||||
.*.swp
|
|
||||||
|
|
||||||
# Visual Studio generated files
|
|
||||||
*.ib_pdb_index
|
|
||||||
*.idb
|
|
||||||
*.ilk
|
|
||||||
*.pdb
|
|
||||||
*.sln
|
|
||||||
*.suo
|
|
||||||
*.vcproj
|
|
||||||
*vcproj.*.*.user
|
|
||||||
*.ncb
|
|
||||||
*.sdf
|
|
||||||
*.opensdf
|
|
||||||
*.vcxproj
|
|
||||||
*vcxproj.*
|
|
||||||
|
|
||||||
# MinGW generated files
|
|
||||||
*.Debug
|
|
||||||
*.Release
|
|
||||||
|
|
||||||
# Python byte code
|
|
||||||
*.pyc
|
|
||||||
|
|
||||||
# Binaries
|
|
||||||
# --------
|
|
||||||
*.dll
|
|
||||||
*.exe
|
|
||||||
|
|
||||||
@ -1,2 +1,2 @@
|
|||||||
Requires Qt6
|
Requires Qt6.
|
||||||
You can open it in QtCreator, but you might have to manually compile the mainwindow.ui with `uic -o ui_mainwindow.h mainwindow.ui` (qt6 uic), since `qtchooser` is not supporting qt6 yet.
|
You can open it in QtCreator, but you might have to manually compile the mainwindow.ui with `uic -o ui_mainwindow.h mainwindow.ui` (qt6 uic), since `qtchooser` is not supporting qt6 yet.
|
||||||
|
|||||||
@ -0,0 +1,113 @@
|
|||||||
|
/********************************************************************************
|
||||||
|
** Form generated from reading UI file 'mainwindow.ui'
|
||||||
|
**
|
||||||
|
** Created by: Qt User Interface Compiler version 6.4.2
|
||||||
|
**
|
||||||
|
** WARNING! All changes made in this file will be lost when recompiling UI file!
|
||||||
|
********************************************************************************/
|
||||||
|
|
||||||
|
#ifndef UI_MAINWINDOW_H
|
||||||
|
#define UI_MAINWINDOW_H
|
||||||
|
|
||||||
|
#include <QtCore/QVariant>
|
||||||
|
#include <QtGui/QAction>
|
||||||
|
#include <QtWidgets/QApplication>
|
||||||
|
#include <QtWidgets/QDoubleSpinBox>
|
||||||
|
#include <QtWidgets/QLabel>
|
||||||
|
#include <QtWidgets/QLineEdit>
|
||||||
|
#include <QtWidgets/QMainWindow>
|
||||||
|
#include <QtWidgets/QMenu>
|
||||||
|
#include <QtWidgets/QMenuBar>
|
||||||
|
#include <QtWidgets/QPushButton>
|
||||||
|
#include <QtWidgets/QStatusBar>
|
||||||
|
#include <QtWidgets/QTextBrowser>
|
||||||
|
#include <QtWidgets/QWidget>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class Ui_MainWindow
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QWidget *centralwidget;
|
||||||
|
QLineEdit *vec1Input;
|
||||||
|
QLineEdit *vec2Input;
|
||||||
|
QLabel *label;
|
||||||
|
QLabel *label_2;
|
||||||
|
QPushButton *okButton;
|
||||||
|
QTextBrowser *outputBrowser;
|
||||||
|
QDoubleSpinBox *factorSpinBox;
|
||||||
|
QLabel *label_3;
|
||||||
|
QMenuBar *menubar;
|
||||||
|
QMenu *menuIst_das_hier_gen_gender_User_Input;
|
||||||
|
QStatusBar *statusbar;
|
||||||
|
|
||||||
|
void setupUi(QMainWindow *MainWindow)
|
||||||
|
{
|
||||||
|
if (MainWindow->objectName().isEmpty())
|
||||||
|
MainWindow->setObjectName("MainWindow");
|
||||||
|
MainWindow->resize(571, 681);
|
||||||
|
centralwidget = new QWidget(MainWindow);
|
||||||
|
centralwidget->setObjectName("centralwidget");
|
||||||
|
vec1Input = new QLineEdit(centralwidget);
|
||||||
|
vec1Input->setObjectName("vec1Input");
|
||||||
|
vec1Input->setGeometry(QRect(110, 30, 391, 51));
|
||||||
|
vec2Input = new QLineEdit(centralwidget);
|
||||||
|
vec2Input->setObjectName("vec2Input");
|
||||||
|
vec2Input->setGeometry(QRect(110, 100, 391, 51));
|
||||||
|
label = new QLabel(centralwidget);
|
||||||
|
label->setObjectName("label");
|
||||||
|
label->setGeometry(QRect(30, 40, 67, 21));
|
||||||
|
label_2 = new QLabel(centralwidget);
|
||||||
|
label_2->setObjectName("label_2");
|
||||||
|
label_2->setGeometry(QRect(30, 110, 67, 21));
|
||||||
|
okButton = new QPushButton(centralwidget);
|
||||||
|
okButton->setObjectName("okButton");
|
||||||
|
okButton->setGeometry(QRect(410, 170, 91, 29));
|
||||||
|
outputBrowser = new QTextBrowser(centralwidget);
|
||||||
|
outputBrowser->setObjectName("outputBrowser");
|
||||||
|
outputBrowser->setGeometry(QRect(30, 220, 511, 391));
|
||||||
|
factorSpinBox = new QDoubleSpinBox(centralwidget);
|
||||||
|
factorSpinBox->setObjectName("factorSpinBox");
|
||||||
|
factorSpinBox->setGeometry(QRect(200, 170, 66, 29));
|
||||||
|
label_3 = new QLabel(centralwidget);
|
||||||
|
label_3->setObjectName("label_3");
|
||||||
|
label_3->setGeometry(QRect(110, 170, 81, 21));
|
||||||
|
MainWindow->setCentralWidget(centralwidget);
|
||||||
|
menubar = new QMenuBar(MainWindow);
|
||||||
|
menubar->setObjectName("menubar");
|
||||||
|
menubar->setGeometry(QRect(0, 0, 571, 26));
|
||||||
|
menuIst_das_hier_gen_gender_User_Input = new QMenu(menubar);
|
||||||
|
menuIst_das_hier_gen_gender_User_Input->setObjectName("menuIst_das_hier_gen_gender_User_Input");
|
||||||
|
MainWindow->setMenuBar(menubar);
|
||||||
|
statusbar = new QStatusBar(MainWindow);
|
||||||
|
statusbar->setObjectName("statusbar");
|
||||||
|
MainWindow->setStatusBar(statusbar);
|
||||||
|
|
||||||
|
menubar->addAction(menuIst_das_hier_gen_gender_User_Input->menuAction());
|
||||||
|
|
||||||
|
retranslateUi(MainWindow);
|
||||||
|
|
||||||
|
QMetaObject::connectSlotsByName(MainWindow);
|
||||||
|
} // setupUi
|
||||||
|
|
||||||
|
void retranslateUi(QMainWindow *MainWindow)
|
||||||
|
{
|
||||||
|
MainWindow->setWindowTitle(QCoreApplication::translate("MainWindow", "MainWindow", nullptr));
|
||||||
|
vec1Input->setText(QCoreApplication::translate("MainWindow", "1.2, 4.3, -2.7, -11", nullptr));
|
||||||
|
vec2Input->setText(QCoreApplication::translate("MainWindow", "-0.9, 4.5", nullptr));
|
||||||
|
label->setText(QCoreApplication::translate("MainWindow", "Vector 1", nullptr));
|
||||||
|
label_2->setText(QCoreApplication::translate("MainWindow", "Vector 2", nullptr));
|
||||||
|
okButton->setText(QCoreApplication::translate("MainWindow", "Ok", nullptr));
|
||||||
|
label_3->setText(QCoreApplication::translate("MainWindow", "Multiply by", nullptr));
|
||||||
|
menuIst_das_hier_gen_gender_User_Input->setTitle(QCoreApplication::translate("MainWindow", "Is this a good enough UI now?", nullptr));
|
||||||
|
} // retranslateUi
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class MainWindow: public Ui_MainWindow {};
|
||||||
|
} // namespace Ui
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif // UI_MAINWINDOW_H
|
||||||
Loading…
Reference in New Issue