Skip to content

Instantly share code, notes, and snippets.

Created December 25, 2014 18:34
Show Gist options
  • Save anonymous/82f6eca4eaaf0ad04192 to your computer and use it in GitHub Desktop.
Save anonymous/82f6eca4eaaf0ad04192 to your computer and use it in GitHub Desktop.
#include <algorithm>
#include <string>
#include <iostream>
#include <stdio.h>
#include <unistd.h>
#include <ctype.h>
#include <time.h>
#include <SFML/Audio.hpp>
void music ();
void files ();
void currenthour ();
void activitypage ();
void titlecheck ();
void gendercheck ();
int title;
int nameValid;
std::string gender;
std::string activity;
int main ()
{
std::string inputName;
beginingoutput:
std::cout << "Good day. Please input your name below." << std::endl;
initialinput:
std::getline(std::cin, inputName);
std::cout << std::endl;
std::transform(inputName.begin(), inputName.end(), inputName.begin(), ::toupper);
inputName.erase(std::remove(inputName.begin(), inputName.end(), ' '), inputName.end());
system("CLS");
if (inputName == "A")
{
currenthour ();
gender = "male";
gendercheck ();
std::cout << "." << std::endl;
nameValid = 1;
activitypage ();
}
else if (inputName == "B")
{
currenthour ();
gender = "female";
gendercheck ();
std::cout << "." << std::endl;
nameValid = 1;
activitypage ();
}
else if (inputName == "C")
{
currenthour ();
gender = "female";
gendercheck ();
std::cout << "." << std::endl;
nameValid = 1;
activitypage ();
}
else if (inputName == "D")
{
currenthour ();
gender = "male";
gendercheck ();
std::cout << "." << std::endl;
nameValid = 1;
activitypage ();
}
else if (inputName == "E")
{
currenthour ();
gender = "male";
title = 3;
titlecheck();
std::cout << "E." << std::endl;
nameValid = 1;
activitypage ();
}
else if (inputName == "F" || inputName == "FA")
{
currenthour ();
gender = "female";
title = 5;
titlecheck ();
std::cout << "F." << std::endl;
nameValid = 1;
activitypage ();
}
else if (inputName == "G")
{
currenthour ();
gender = "male";
title = 6;
titlecheck();
std::cout << "G." << std::endl;
nameValid = 1;
activitypage ();
}
else
{
std::cout << "My most sincere apologies, but I do not recognise that name, could you please input it again?" << std::endl;
goto initialinput;
}
}
void activitypage ()
{
if (nameValid == 1)
{
std::cout << "What would you like to do today, ";
gendercheck ();
std::cout << "?" << std::endl;
std::cout << "> Music" << std::endl;
std::cout << "> Files" << std::endl;
std::cout << "> New User" << std::endl;
std::cout << "> Exit" << std::endl;
std::getline(std::cin, activity);
std::cout << std::endl;
std::transform(activity.begin(), activity.end(), activity.begin(), ::toupper);
activity.erase(std::remove(activity.begin(), activity.end(), ' '), activity.end());
system("CLS");
if (activity == "MUSIC")
{
music ();
}
else if (activity == "FILES")
{
files ();
}
else if (activity == "NEWUSER")
{
main ();
}
if (activity == "EXIT")
{
std::cout << "Shutting down. Goodbye.";
sleep(2);
return;
}
}
}
void currenthour()
{
time_t now;
struct tm *now_tm;
int hour;
now = time(NULL);
now_tm = localtime(&now);
hour = now_tm->tm_hour;
if (hour >= 0 && hour <= 5)
{
std::cout << "It is terribly late. You should rest ";
}
else if (hour >= 6 && hour <= 11)
{
std::cout << "Good morning ";
}
else if (hour >= 12 && hour <= 17)
{
std::cout << "Good afternoon ";
}
else if (hour >= 18 && hour <= 23)
{
std::cout << "Good evening ";
}
else
{
std::cout << "Hello ";
}
}
void gendercheck ()
{
if (gender == "male")
{
title = 1;
titlecheck ();
}
else if (gender == "female")
{
title = 2;
titlecheck ();
}
else if (gender == "youngmale")
{
title = 7;
titlecheck ();
}
else if (gender == "youngfemale")
{
title = 4;
titlecheck ();
}
}
void titlecheck ()
{
if (title == 1)
{
std::cout << "sir";
}
else if (title == 2)
{
std::cout << "ma'am";
}
else if (title == 3)
{
std::cout << "Master ";
}
else if (title == 4)
{
std::cout << "Miss ";
}
else if (title == 5)
{
std::cout << "Mrs. ";
}
else if (title == 6)
{
std::cout << "Mr. ";
}
else if (title == 7)
{
std::cout << "Master";
}
}
void music ()
{
system("CLS");
sf::Music WorldOnFire;
std::string musicInput;
std::cout << "What would you like to listen to?" << std::endl;
std::cout << "> Track 1 - \"I Don't Want to Set the World on Fire\" by The Ink Spots" << std::endl;
std::getline(std::cin, musicInput);
std::cout << std::endl;
std::transform(musicInput.begin(), musicInput.end(), musicInput.begin(), ::toupper);
musicInput.erase(std::remove(musicInput.begin(), musicInput.end(), ' '), musicInput.end());
if (musicInput == "TRACK1" || musicInput == "TRACK1-\"IDON'TWANTTOSETTHEWORLDONFIRE\"" || musicInput == "TRACK1-\"IDON'TWANTTOSETTHEWORLDONFIRE\"BYTHEINKSPOTS" || musicInput == "\"IDON'TWANTTOSETTHEWORLDONFIRE\"" || musicInput == "IDON'TWANTTOSETTHEWORLDONFIRE")
{
if (!WorldOnFire.openFromFile("IDontWantToSetTheWorldOnFire.ogg"))
{
std::cout << "Could not open file. File corrupted or missing." << std::endl;
std::cin.ignore();
music();
}
WorldOnFire.play();
}
}
void files ()
{
system("CLS");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment