Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ##############################################
- Program name : Login Example
- Description : Login program for learners
- Author : Derek Brazil
- Date : 27/08/2016
- ##############################################
- Before other programmers look at this and say ew.
- I used If statments as a loop because it was easlier to clarify.
- */
- #pragma region Includes
- #include "stdafx.h"
- #include <iostream>
- #include <string>
- #include <cstdlib>
- #include <cmath>
- #include <cstring>
- #include <Windows.h>
- using namespace std;
- #pragma endregion
- #pragma region Functions
- template <typename T>
- void output(T shit) {
- cout << shit << endl;
- };
- void Restart()
- {
- cout << "\n" << endl;
- string Userlist[5] = { "Martin", "Derek", "Caitlin", "Dean", "Sarah" };
- string Passlist[5] = { "Martin123", "Derek123", "Caitlin123", "Dean123", "Sarah123" };
- cout << "Below is a list of User's" << endl;
- for (int i = 0; i < 5; i++)
- {
- cout << Userlist[i] << endl;
- }
- cout << "\n" << endl;
- string username;
- string password;
- cout << "Type your Username : ";
- cin >> username;
- cout << "Type your Password : ";
- cin >> password;
- for (int i = 0; i <= sizeof(Userlist); i++) {
- if (Userlist[i] == username && Passlist[i] == password) {
- cout << "You have been logged in, max Int capacity is ";
- switch (i) {
- case 1:
- output(MAXINT);
- break;
- case 2:
- output(MAXBYTE);
- break;
- case 3:
- output(MAXCHAR);
- break;
- case 4:
- output(MAXLONG);
- break;
- case 5:
- output(MAXWORD);
- break;
- default:
- output("Error wrong username or password");
- }
- }
- }
- }
- /*
- if (username == Userlist[1] & password == Passlist[1]) {
- cout << "You have been logged in" << endl; cout << "Max Int Capacity is : " << MAXINT << endl;
- }
- else if (username == Userlist[0] & password == Passlist[0]) {
- cout << "You have been logged in" << endl; cout << "Max Byte Capacity is : " << MAXBYTE << endl;
- }
- else if (username == Userlist[2] & password == Passlist[2]) {
- cout << "You have been logged in" << endl; cout << "Max Char Capacity is : " << MAXCHAR << endl;
- }
- else if (username == Userlist[3] & password == Passlist[3]) {
- cout << "You have been logged in" << endl; cout << "Max Long Capacity is : " << MAXLONG << endl;
- }
- else if (username == Userlist[4] & password == Passlist[4]) {
- cout << "You have been logged in" << endl; cout << "Max Word Capacity is : " << MAXDWORD << endl;
- }
- else {
- cout << "Error wrong username or password" << endl;
- }
- }
- */
- void wrongInput()
- {
- cout << "Type \"Restart\" to try again : ";
- string restart;
- cin >> restart;
- if (restart == "Restart")
- {
- Restart();
- }
- else
- {
- cout << "Input not valid!" << endl;
- }
- }
- void Program() {
- cout << "Please login to get the max \"int\" value capacity" << endl;
- string Userlist[5] = { "Martin", "Derek", "Caitlin", "Dean", "Sarah" };
- string Passlist[5] = { "Martin123", "Derek123", "Caitlin123", "Dean123", "Sarah123" };
- cout << "Below is a list of User's" << endl;
- for (int i = 0; i < 5; i++)
- {
- cout << Userlist[i] << endl;
- }
- string username;
- string password;
- cout << "Type your Username : ";
- cin >> username;
- cout << "Type your Password : ";
- cin >> password;
- if (username == Userlist[1] & password == Passlist[1]) {
- cout << "You have been logged in" << endl; cout << "Max Int Capacity is : " << MAXINT << endl;
- }
- else if (username == Userlist[0] & password == Passlist[0]) {
- cout << "You have been logged in" << endl; cout << "Max Byte Capacity is : " << MAXBYTE << endl;
- }
- else if (username == Userlist[2] & password == Passlist[2]) {
- cout << "You have been logged in" << endl; cout << "Max Char Capacity is : " << MAXCHAR << endl;
- }
- else if (username == Userlist[3] & password == Passlist[3]) {
- cout << "You have been logged in" << endl; cout << "Max Long Capacity is : " << MAXLONG << endl;
- }
- else if (username == Userlist[4] & password == Passlist[4]) {
- cout << "You have been logged in" << endl; cout << "Max Word Capacity is : " << MAXDWORD << endl;
- }
- else {
- cout << "Error wrong username or password" << endl;
- cout << "Type \"Restart\" to try again : " << flush;
- string restart;
- cin >> restart;
- if (restart == "Restart")
- {
- Restart();
- }
- else
- {
- cout << "Input not valid!" << endl;
- for (;;) {
- wrongInput();
- }
- }
- }
- }
- cout << "Thanks for using my program will restart in 5 seconds :)\n" << endl;
- Sleep(5000);
- #pragma endregion
- #pragma region Main
- int main()
- {
- while(true){
- Program();
- }
- return 0;
- }
- #pragma endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement