GoldenEye: Source Forums

  • November 15, 2024, 10:45:53 pm
  • Welcome, Guest
Advanced search  

News:

Pages: [1]   Go Down

Author Topic: C++ classes finally over  (Read 7353 times)

0 Members and 3 Guests are viewing this topic.

Kratos

  • 007
  • ****
  • Posts: 1,157
  • Reputation Power: 125
  • Kratos is awe-inspiring!Kratos is awe-inspiring!Kratos is awe-inspiring!Kratos is awe-inspiring!Kratos is awe-inspiring!Kratos is awe-inspiring!Kratos is awe-inspiring!Kratos is awe-inspiring!Kratos is awe-inspiring!Kratos is awe-inspiring!Kratos is awe-inspiring!Kratos is awe-inspiring!
  • Offline Offline
C++ classes finally over
« on: October 03, 2012, 05:43:40 pm »

FINALLY i have completed both C++ classes. The intermediate C++ course i just passed this recent semester, we had to create a file on the c: and open the file, load the shit from in it, and display it on the screen. I fucking spent hours trying to load the fucker, but it wouldnt do shit.  DEBUG DEBUG DEBUG!!!!

Then I let my uncle have a look at it, and somehow with his magical fingers, he was able to get it working. We also had to load arrays, sort them (bubble sort array) and bunch of other stuff.

I have potential in programming. I don't want to give up. When I was working on my other assignments and I ran them, they didnt work, so I spent time debugging and when I ran it again, it worked fine. You get that feeling of enjoyment when you spend hours on coding and it fucking runs without throwing syntax errors!

I will still continue to code on my free time to learn more. Even though I had tough times in this class, I still enjoyed it. It was a fun ride.

 My brain got tired after staring at the screen for weeks. Now for the upcoming semester, I'm taking access programming.

Here is sample of some code I did.

Code: [Select]
#include <fstream>
#include <iostream>
#include <string>

using namespace std;

char answer = 'y';

double passengers, flight_no, menu_option;
string origin, repeat_prog, destination, flight_code, c, d, o, D, C, O, cancelled, ontime, delayed;

ofstream fout;
ifstream fin;

void setup ();
void input ();
void output ();
void menu();


int main()
{

setup();

cout << "Is this correct program you want to run" << endl;
cout << "Please type Y(y) for yes and N(n) for no" << endl;
cin >> repeat_prog;


while ( repeat_prog != "y"  && repeat_prog != "n"  )
{
cout << "ERROR!!" << endl;
cout << "Please type Y for yes and N for no" << endl;
cin >> repeat_prog;
}

if ( repeat_prog == "n" || repeat_prog == "N")
{
return 0;
}

menu();

system("pause");

return 0;


}

void setup()
{

delayed = "d";
cancelled = "c";
ontime = "o";

}

void menu()
{
   menu_option = 1;
   while (menu_option != 3)
   {
cout << endl;
cout << "1. Create a new file"
<< endl;
cout << "2. Open created file"
<< endl;
cout << "3. End the program" << endl;
cout << endl;
cout << "Choose a menu option: ";
cin >> menu_option;
cout << endl;

if (menu_option == 3) break;

if ( menu_option == 1 )
input();

    if ( menu_option == 2 )
  output();
   }
   cout << "Program Ended..." << endl;
}

void input()
{
//File init
fout.open ("c:\\study\\airline_data.txt",ifstream::app);
fout.seekp(0,ios::end);

//Data input
cout << "Flight No: ";
cin >> flight_no;
cout << "Origin: ";
cin >> origin;
cout << "Destination: ";
cin >> destination;
cout << "Passengers: ";
cin >> passengers;
cout << "Flight Code:";
cin >> flight_code;

//Data validation
while ( flight_code != "d" && flight_code != "c" && flight_code != "o" && flight_code != "D" && flight_code != "C" && flight_code != "O" )
{
cout << "ERROR!!" << endl;
cout << "Please type d for delayed, c for cancelled, o for ontime!" << endl;
cin >> flight_code;
}

//save data
fout << flight_no << origin << destination << passengers << flight_code;

//close file
fout.close();

}

void output()
{
fin.open("C:\\study\\airline_data.txt");     
fin.seekg(0,ios::beg);

while ( !fin.eof() )
{
fin >> flight_no >> origin >> destination >> passengers >> flight_code;

cout << flight_no << "\t";
cout << origin  << "\t";
cout << destination  << "\t";
cout << passengers  << "\t";
cout << flight_code  << "\t";
}

fin.close ();
}
« Last Edit: October 03, 2012, 05:46:27 pm by Terrowrist »
Logged

mbsurfer

  • Inactive Tester
  • 00 Agent
  • ***
  • Posts: 794
  • Reputation Power: 41
  • mbsurfer is a force to reckon with.mbsurfer is a force to reckon with.mbsurfer is a force to reckon with.mbsurfer is a force to reckon with.mbsurfer is a force to reckon with.mbsurfer is a force to reckon with.mbsurfer is a force to reckon with.mbsurfer is a force to reckon with.
  • Offline Offline
Re: C++ classes finally over
« Reply #1 on: October 04, 2012, 12:55:16 am »

Glad you enjoyed it. When I first started programming I got hooked. I am surprised they didn't teach you object oriented c++ yet though.
Logged

Proxie

  • 00 Agent
  • ***
  • Posts: 573
  • Reputation Power: 141
  • Proxie is awe-inspiring!Proxie is awe-inspiring!Proxie is awe-inspiring!Proxie is awe-inspiring!Proxie is awe-inspiring!Proxie is awe-inspiring!Proxie is awe-inspiring!Proxie is awe-inspiring!Proxie is awe-inspiring!Proxie is awe-inspiring!Proxie is awe-inspiring!Proxie is awe-inspiring!
  • Offline Offline
Re: C++ classes finally over
« Reply #2 on: October 04, 2012, 04:31:21 pm »

Congratulations.  I'm going to start teaching myself C#, hopefully already knowing Python will help.
Logged

killermonkey

  • GES Programmer
  • Retired Lead Developer
  • GE:S Fanatic
  • *
  • Posts: 5,473
  • Reputation Power: 346
  • killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!
  • Offline Offline
    • DroidMonkey Apps
Re: C++ classes finally over
« Reply #3 on: October 04, 2012, 06:48:04 pm »

Proxie, I just finished half of C# 4 in a Nutshell, totally suggest it.

http://www.amazon.com/gp/aw/d/0596800959/ref=mp_sim_s_4?pi=SL500_SY125

C# is what Java should have been.
« Last Edit: October 04, 2012, 06:51:14 pm by killermonkey »
Logged
Pages: [1]   Go Up