View Full Version : Drags Coding Probs
Dragonstorm
10-07-2005, 11:02 AM
I'm in Uni, and doing some computing, god its dull!!
someonem PLEASe be here and chat to meee!! :cry: :cry:
Dragonstorm
10-07-2005, 11:07 AM
DAmmit?!!!! Where is everyone!?!??! =(
Jekht
10-07-2005, 11:17 AM
muahahaha i agree, where is every1 when u need to spam the forums most! :(
im bored of working
0bitus
10-07-2005, 11:19 AM
http://thatvideosite.com/view/598.html
Dammit someone posted a link to that site on the mxo fourms.. its so damn addictive. But that episode 3 trailer rocks lol
Dragonstorm
10-07-2005, 11:34 AM
Rarr!!! People!!
Programming sucks =( It's so damned DULL
Tytanya
10-07-2005, 11:55 AM
If you're at Uni, shouldnt you be like, you know, learning stuff? :wink:
HoniezUk
10-07-2005, 12:07 PM
im here..and its odd how the matrix is so emptie O.o
Dragonstorm
10-07-2005, 12:52 PM
Hehe, I am Learning, jsut made me this beauty
http://img372.imageshack.us/img372/720/untitled1ho.jpg
Which for my first lesson starting from a blank page and guessing most of the commands wasnt easy!! hehe
#include <iostream.h>
#include <iomanip.h>
const float CONV_RATE = 0.75;
const int DECIMAL_PLACES = 2;
void main()
{
float CASH;
float CASHCONV;
cout << "How many pounds do you wish to convert? " << endl;
cin >> CASH;
cout << endl;
cout << endl;
CASHCONV = CASH / CONV_RATE;
cout << fixed << showpoint << setprecision(DECIMAL_PLACES);
cout << "Your " << CASH << " Pounds are worth " << CASHCONV << " Dollars," <<endl;
cout << "at a rate of 0.75 Pounds to the Dollar." << endl;
system("pause");
} // end main
Tytanya
10-07-2005, 01:03 PM
hmm not bad, for a first attempt..... I'm sooo out of date, what language is that?
Dragonstorm
10-07-2005, 01:03 PM
#include <iostream.h>
#include <iomanip.h>
const int DECIMAL_PLACES = 2;
void main()
{
float CASH;
float CONV_RATE;
float CASHCONV;
cout << "How many pounds do you wish to convert? " << endl;
cin >> CASH;
cout << endl;
cout << "What is the current conversion rate? (xx pounds to 1 dollar)" << endl;
cin >> CONV_RATE;
cout << endl;
cout << endl;
CASHCONV = CASH / CONV_RATE;
cout << fixed << showpoint << setprecision(DECIMAL_PLACES);
cout << "Your " << CASH << " Pounds are worth " << CASHCONV << " Dollars," <<endl;
cout << "at a rate of " << CONV_RATE << " Pounds to the Dollar." << endl;
system("pause");
} // end main
Updated, ooooh!! hehe, now has an extra step in it ^^
Oh, and I know most of you can jsut look at this and laugh cause it's so easy, but hey, I've only jsut started, and I'm happy, so cut me a li'l slack!
Oh and ty, it's C++
Dragonstorm
10-07-2005, 01:06 PM
Oh, and if anyone wants to help, go to http://ww.lindasnape.com and start working through the exercises!! hehe Feel free to just drop them my way, hahah
Oh, and I just found out there's some notes on that site too that I'm supposed to be using, hehe. Might be easier than the guessing I'm doing now!
Dragonstorm
10-07-2005, 01:40 PM
Yay!! It's getting quite easy now I've got past the first bit of learning the commands. Spinning off laods of them now, which is definately more fun!
HoniezUk
10-07-2005, 01:44 PM
nice one DS. keep going ..yuoll get there
sorry to go of topic...but who is this? lol..
sorry >.<
i got bored too
MXO new spawn of Agent?
http://img134.imageshack.us/img134/6932/677kq.jpg
Dragonstorm
10-07-2005, 01:52 PM
Hehe, you got a bit too much time on your hands aswell there Hon? hehe
And it's not like you can really go off-topic in one of my threads!! :wink:
HoniezUk
10-07-2005, 01:57 PM
too much time?...i wont lie...yes i do...every freaking day >.< if im not asleep im on here..thats what greece is done to me.. >.< no matter il be gone in a month and il be wishing i never left...
Dragonstorm
10-09-2005, 11:25 PM
Right, got bored. Did my assignment for in a month that I dont get til tomorrow all tonight... I'm pretty happy, hehe.
Oh, if anyone knows how to help, with the huge "do while loop" over the whole program, when it repeats, it skips the first "cin.getline". thats why I put the pause in. If anyone knows how to fix that, please say!
#include <iostream.h>
#include <iomanip.h>
void main()
{
// Variables
const int name_length = 25; // Max name length
char name[name_length]; // Name of user
const int date_length = 25; // Max date length
char date[date_length]; // Name of user
int group_size; // Size of the group
int group_size_loop_count = 0; // Used for Group_size loop display message
int duration; // Length of times in hours
int duration_loop_count = 0; // Used for Group_size loop display message
float charge_rate; // Charge per hour per person
float charge; // Charge for the booked session
int no_of_paintballs; // Number of paintballs
const int paintballs_per_person = 20; //Standards painballs per person
int free_paintballs; // Free paintballs
int free_group_size; // Used for Free paintballs calculation
char equipment_hire; // Used for Equipment Hiring loop
int equip_hire_loop_count = 0; // Used for Hiring loop display message
char equipment_hire_output; // Displays if equipment is hired on the end form
char paintball_order; // Used for Equipment Hiring loop
int paintball_order_loop_count = 0; // Used for Hiring loop display message
int ordered_paintballs = 0; // No. of Extra Paintballs ordered
int paintball_cost = (1 / 600); // Cost of ordered paintballs
char program_repeat; // Used in program repeat
int program_repeat_loop_count = 0; // Used in program repeat
char repeat; // Used in program repeat
char reapeat_begin; // Needed to stop skipping
// Program Repeat Beginning
do
{
system("pause");
// Name Input
cout << endl;
cout << "Please enter your name, Initials and Surname. " << endl;
cout << "e.g. A N Other - Max 25 Chars. " << endl;
cout << endl;
cin.getline(name, name_length);
cout << endl;
cout << endl;
// Date Input
cout << "Please enter your name, in the format DD/MM/YYYY " << endl;
cout << "e.g. 10/03/2006 " << endl;
cout << endl;
cin.getline(date, date_length);
cout << endl;
cout << endl;
// Group Size Input Loop
do
{
if (group_size_loop_count >= 1) {cout << "Invalid Group Size - Please select another. (30 max) " << endl;};
cout << "What is the size of the group? " << endl;
cout << endl;
cin >> group_size;
cout << endl;
cout << endl;
group_size_loop_count++;
} while (group_size < 1 || group_size > 30);
// Duration Input Loop
do
{
if (duration_loop_count >= 1) {cout << "Invalid Duration - Please select another. (10 max) " << endl;};
cout << "What is the duration of the booking? (Whole hours only) " << endl;
cout << endl;
cin >> duration;
cout << endl;
cout << endl;
duration_loop_count++;
} while (duration < 1 || duration > 10);
// Charge Rate Calculation
if (duration == 1) { charge_rate = 2.60; }; //Longer durations apply different charge rates
if (duration == 2) { charge_rate = 2.60; };
if (duration == 3) { charge_rate = 2.30; };
if (duration == 4) { charge_rate = 2.30; };
if (duration == 5) { charge_rate = 2.30; };
if (duration == 6) { charge_rate = 2.10; };
if (duration == 7) { charge_rate = 2.10; };
if (duration == 8) { charge_rate = 2.00; };
if (duration == 9) { charge_rate = 2.00; };
if (duration == 10) { charge_rate = 2.00; };
// Free Paintballs Calulation
free_group_size = group_size / 5; // Gives a more compact table for calculations
if (free_group_size == 0) { free_paintballs = 0; }; // Bigger groups give more free paintballs
if (free_group_size == 1) { free_paintballs = 0; };
if (free_group_size == 2) { free_paintballs = 0; };
if (free_group_size == 3) { free_paintballs = 50; };
if (free_group_size == 4) { free_paintballs = 100; };
if (free_group_size == 5) { free_paintballs = 160; };
if (free_group_size == 6) { free_paintballs = 250; };
// Charge and No. Paintballs calculations
charge = charge_rate * duration * group_size; // Calculates the charge based on group size and duration
no_of_paintballs = paintballs_per_person * group_size; // Calculates the base number of paintballs
no_of_paintballs = no_of_paintballs + free_paintballs; // Adds any free paintballs to the counter
// Equipment Hire Loop + Additional Charges
while (equipment_hire != 'Y' && equipment_hire != 'y' && equipment_hire != 'N' && equipment_hire != 'n')
{
if (equip_hire_loop_count >= 1) {cout << "Please answer Y or N." << endl;};
cout << "Do you wish to hire equipment? " << endl;
cout << endl;
cin >> equipment_hire;
cout << endl;
cout << endl;
equip_hire_loop_count++; // Adds one to loop count, to display "Please" msg.
}
if (equipment_hire == 'Y' || equipment_hire == 'y') {charge = charge + 5;}; // Only charges if equipment is hired, adding charge to total
// Equipment Hire Output Form
if (equipment_hire == 'Y' || equipment_hire == 'y') {equipment_hire_output = 'Y';}; // Changes Y/y to capitol for final output
if (equipment_hire == 'N' || equipment_hire == 'n') {equipment_hire_output = 'N';}; // Changes N/n to capitol word for final output
// Paintball Order Loop + Additional Charges
while (paintball_order != 'Y' && paintball_order != 'y' && paintball_order != 'N' && paintball_order != 'n')
{
if (paintball_order_loop_count >= 1) {cout << "Please answer Y or N." << endl;};
cout << "Do you wish to order any extra paintballs? " << endl;
cout << endl;
cin >> paintball_order;
cout << endl;
cout << endl;
paintball_order_loop_count++; // Adds one to loop count, to display "Please" msg.
};
if (paintball_order == 'Y' || paintball_order == 'y') // Only displays if Paintballs are ordered
{
cout << "How many paintballs would you like to order? " << endl;
cout << "Note that the Paintballs are sold in 100's. " << endl;
cout << endl;
cin >> ordered_paintballs;
};
charge = charge + (ordered_paintballs * paintball_cost); // Adds order to total charge, whether 0 or more
no_of_paintballs = no_of_paintballs + ordered_paintballs; // Adds order to paintball total
cout << endl;
cout << endl;
// Output - Displays collected and relevant data
cout << endl;
cout << endl;
cout << "--------------------------------------------------------------------------------" << endl;
cout << " Name | Date | Duration | Group | Equipment | Total | Total |" <<endl;
cout << " | | | Size | Hire | Paintballs | Cost | " << endl;
cout << "--------------------------------------------------------------------------------" << endl;
cout << setw (12) << name << "|" << setw (12) << date << "|" << setw (10) << duration << "|" << setw (7)
<< group_size << "|" << setw (11) << equipment_hire_output << "|" << setw (12) << no_of_paintballs
<< fixed << showpoint << setprecision(2) << "|" << setw (9) << charge << endl;
cout << "--------------------------------------------------------------------------------" << endl;
cout << endl; // Formated into a table with <x> spaces for each value
cout << endl;
cout << endl;
// Program Repeat End
while (program_repeat != 'Y' && program_repeat != 'y' && program_repeat != 'N' && program_repeat != 'n')
{
if (program_repeat_loop_count >= 1) {cout << "Please answer Y or N." << endl;};
cout << "Do you wish to make another booking? " << endl;
cout << endl;
cin >> program_repeat;
cout << endl;
cout << endl;
program_repeat_loop_count++; //Adds one to loop count, to display "Please" msg.
}
if (program_repeat == 'N' || program_repeat == 'n') {repeat = 'N';};
} while (repeat != 'N');
// Program End
cout << endl;
cout << "Thank you for booking. " << endl;
cout << endl;
system("pause");
}
Veube
10-10-2005, 09:34 AM
Nice coding DS. The type of problem you're describing is most annoying, as it looks like it should work. It's probably something perculiar to the system you're running on.
My guess is that on the second run through, without the 'pause', there's something left in the input buffer that the getline function grabs.
Try outputting those 2 variables to see whats in them on a second run, might give a clue. If that is the case then a dummy getline call at the bottom of the loop just before it loops might clear the input buffer and remove the need for the pause.
Looks like you're on the road to becoming an uber dev. Is there a Java course in your degree ? That's the way forward IMO, then you only have to code once for all platforms and environments. PCs, Macs (bleh), Linux / other OSs, PDAs, mobiles, etc.And its all open source and free. You can download the Java Development Kit from www.sun.com/java and there's tons of tutorials and help etc. Anyway, enough of the sales pitch, lol.
Jekht
10-10-2005, 12:25 PM
V do u have a pyramid scheme i can sign up to? Im most interested in giving u money!
Dragonstorm
10-10-2005, 12:41 PM
I jsut asked my teacher before I read that V, and you're exactly right ^^
Easiest solution is jsut to use flush(); apparently!
EDIT - Got it to work perfectly, so thats 1/5th of my module done, hehehe
Thx for the help V ^^
Seriphin
10-10-2005, 12:46 PM
O___O;; *twitch* My brain hurts...x___x :?: :shock:
0bitus
10-10-2005, 01:03 PM
Whens Serphin comming back?
Seriphin
10-10-2005, 08:24 PM
I doubt if ever. Considering they yanked the game cards and my parents don't have a credit card to give me .___.;;. Unless someone's got a credit card they don't mind giving me the info to, I'm royally screwed TT___TT.
Jekht
10-10-2005, 08:41 PM
hrm, u not able to ask ur 'rents/mate to pay a month or sumthin as a gift?
anyways, I havnt been on last 3 days as RL royally screwed me over... so I went out and bought BW2 to try and cheer myself up... and Iv been burning villages to the ground and u know what? It helps! :D
I'l come back ingame when Im sure I wont have a random rant at one of u just cus Im pissed off. S'pose at least things can only get better :)
Dragonstorm
10-11-2005, 10:24 AM
Hehe, Ditto in a way J, RL is mad atm and I havent been around much either. Uni is going really goods though!! hehe Thanks to V's help =P
Anyways, I might come and Jack in for a bit!
Seriphin
10-11-2005, 08:02 PM
Lol, Don't forget Jek, I'm only 14 and I live with my parents still, of course. I don't have anyone else to bug for a card other than you guys, and thats about as helpful as asking for water in the middle of the desert. No offense of course. ^__^;;
Dragonstorm
10-12-2005, 05:36 PM
Right, Just another question that is bugging me
All my symbols work fine when I stick them in a
cout << "symbols here" << endl;
situation, all except £, which comes out as a U with an accent on it.
Just wondering if anyone knows why its doing this or how to get round it. I'm looking at key mappings etc, but no luck as of yet! =(
I get that it's an illegal character, but how do I get round this?
Veube
10-12-2005, 07:26 PM
What you're using the type the code and where you're running the program are different environments, using different fonts ?
It's probably just that, for instance if you use the Character Map utility in Windows you'll see that the pound sign is in a different place in the 'Terminal' font from say 'Arial'.
I guess the way I'd do it would be to make a new char variable:
char poundsign=156; (for £ in terminal font)
then when you output do:
cout << poundsign << "blah blah blah" << endl;
Dragonstorm
10-12-2005, 07:33 PM
God damn you're good ^^ Thanks again V, really saving me so much hassle here!! *hugs for you!*
Btw, where did you get 156 from, just so I know how to find them on my own instead of bugging you!
Jekht
10-12-2005, 07:36 PM
rock on! :D I wish I knew how to code better! I started learning how to code batch files to use as pratical jokes, but never really went much further than that :S
Dragonstorm
10-12-2005, 07:39 PM
Well, found a way to do what you did, which is go on char map, then find what I want on Terminal, then just change the Hex to numbers, so 9C in this case was 156. If thats not what you did though, and theirs a better way, then please share!! hehe
Veube
10-12-2005, 07:54 PM
That's the way to do it. ::sqwaaarrk::
:?
Dragonstorm
10-12-2005, 07:57 PM
Well anyways, here is my code now. I'm pretty happy with it for about 3 days of actual learning, hehe ^^ Any suggestions, comments, etc. then please feel free to make them!
#include <iostream.h> // I/O
#include <iomanip.h> // I/O fomatting
#include <conio.h> // I/O getline()
void main()
{
// Variables
const int name_length = 25; // Max name length
char name[name_length]; // Name of user
const int date_length = 25; // Max date length
char date[date_length]; // Name of user
int group_size; // Size of the group
int group_size_loop_count = 0; // Used for Group_size loop display message
int duration; // Length of times in hours
int duration_loop_count = 0; // Used for Group_size loop display message
float charge_rate; // Charge per hour per person
float charge; // Charge for the booked session
int no_of_paintballs; // Number of paintballs
const int paintballs_per_person = 20; //Standards painballs per person
int free_paintballs; // Free paintballs
int free_group_size; // Used for Free paintballs calculation
char equipment_hire; // Used for Equipment Hiring loop
int equip_hire_loop_count = 0; // Used for Hiring loop display message
char equipment_hire_output; // Displays if equipment is hired on the end form
char paintball_order; // Used for Equipment Hiring loop
int paintball_order_loop_count = 0; // Used for Hiring loop display message
int ordered_paintballs; // No. of Extra Paintballs ordered
int paintball_cost = (1 / 600); // Cost of ordered paintballs
char confirmation; // Confirmation of details
int confirmation_loop_count = 0; // Confirmation of details loop
char program_repeat; // Used in program repeat
int program_repeat_loop_count = 0; // Used in program repeat
char repeat; // Used in program repeat
char reapeat_begin; // Needed to stop skipping
char pound_sign = 156; // Allows £ to be used on outputs.
// Program Repeat Beginning
do // Loops entire program
{
flushall(); // Clears input streams to prevent question skip on restart
system ("cls"); // Clears screen for program start/repeat
// Title
cout << "--------------------------------------------------------------------------------" << endl;
cout << "||| |||" << endl;
cout << "|| Welcome to the Paintball Booking Service ||" << endl;
cout << "||| |||" << endl;
cout << "--------------------------------------------------------------------------------" << endl;
cout << endl;
cout << endl;
cout << endl;
// Name Input
cout << endl;
cout << "Please enter your name, Initials and Surname. " << endl;
cout << "e.g. A N Other - Max 25 Chars. " << endl;
cout << endl;
cin.getline(name, name_length);
cout << endl;
cout << endl;
// Date Input
cout << "Please enter the date of booking, in the format DD/MM/YYYY. " << endl;
cout << "e.g. 19/03/2006 " << endl;
cout << endl;
cin.getline(date, date_length);
cout << endl;
cout << endl;
// Group Size Input Loop
do
{
if (group_size_loop_count >= 1)
{
cout << "For safety reasons, we only allow a maximum of 30 people per group. " << endl;
cout << "Please try splitting into smaller groups, and making multiple bookings." << endl;
cout << endl;
};
cout << "How many people are in your group for this booking? " << endl;
cout << endl;
if(!(cin >> group_size)) // Tells user to use correct input on error
{
cout << "Please enter numerical values only." << endl;
cout << endl;
};
cin.clear(); // Clears buffers to prevent looping error and decimal input error
cin.ignore(100,'\n'); // Ignores the invalid input to prevent looping error
group_size_loop_count++;
cout << endl;
cout << endl;
} while (group_size < 1 || group_size > 30);
// Duration Input Loop
do
{
if (duration_loop_count >= 1)
{
cout << "Sorry, but we only allow for matches up to 10 hours long " << endl;
cout << "Please enter a smaller duration." << endl;
cout << endl;
};
cout << "How long would you like this match to last? (Whole hours only) " << endl;
cout << endl;
if(!(cin >> duration))
{
cout << "Please enter numerical values only." << endl;
cout << endl;
};
cin.clear();
cin.ignore(100,'\n');
duration_loop_count++;
cout << endl;
cout << endl;
} while (duration < 1 || duration > 10);
// Charge Rate Calculation
if (duration == 1) { charge_rate = 2.60; }; // Longer durations apply different charge rates
if (duration == 2) { charge_rate = 2.60; };
if (duration == 3) { charge_rate = 2.30; };
if (duration == 4) { charge_rate = 2.30; };
if (duration == 5) { charge_rate = 2.30; };
if (duration == 6) { charge_rate = 2.10; };
if (duration == 7) { charge_rate = 2.10; };
if (duration == 8) { charge_rate = 2.00; };
if (duration == 9) { charge_rate = 2.00; };
if (duration == 10) { charge_rate = 2.00; };
// Free Paintballs Calulation
free_group_size = group_size / 5; // Gives a more compact table for calculations
if (free_group_size == 0) { free_paintballs = 0; }; // Bigger groups give more free paintballs
if (free_group_size == 1) { free_paintballs = 0; };
if (free_group_size == 2) { free_paintballs = 0; };
if (free_group_size == 3) { free_paintballs = 50; };
if (free_group_size == 4) { free_paintballs = 100; };
if (free_group_size == 5) { free_paintballs = 160; };
if (free_group_size == 6) { free_paintballs = 250; };
// Charge and No. Paintballs calculations
charge = charge_rate * duration * group_size; // Calculates the charge based on group size and duration
no_of_paintballs = paintballs_per_person * group_size; // Calculates the base number of paintballs
no_of_paintballs = no_of_paintballs + free_paintballs; // Adds any free paintballs to the counter
// Equipment Hire Loop + Additional Charges
while (equipment_hire != 'Y' && equipment_hire != 'y' && equipment_hire != 'N' && equipment_hire != 'n')
{
if (equip_hire_loop_count >= 1)
{
cout << "Please answer Y or N." << endl;
cout << endl;
};
cout << "Do you wish to hire equipment, at a cost of " << pound_sign << "5 per group? " << endl;
cout << endl;
cin >> equipment_hire;
cout << endl;
cout << endl;
equip_hire_loop_count++; // Adds one to loop count, to display "Please" msg.
}
if (equipment_hire == 'Y' || equipment_hire == 'y') {charge = charge + 5;}; // Only charges if equipment is hired, adding charge to total
// Equipment Hire Output Form
if (equipment_hire == 'Y' || equipment_hire == 'y') {equipment_hire_output = 'Y';}; // Changes Y/y to capitol for final output
if (equipment_hire == 'N' || equipment_hire == 'n') {equipment_hire_output = 'N';}; // Changes N/n to capitol word for final output
// Paintball Order Loop
while (paintball_order != 'Y' && paintball_order != 'y' && paintball_order != 'N' && paintball_order != 'n')
{
if (paintball_order_loop_count >= 1)
{
cout << "Please answer Y or N." << endl;
cout << endl;
};
cout << "Do you wish to order any extra paintballs? " << endl;
cout << endl;
cin >> paintball_order;
cout << endl;
cout << endl;
paintball_order_loop_count++; // Adds one to loop count, to display "Please" msg.
}
// Number of paintballs desired and additional cost
if (paintball_order == 'Y' || paintball_order == 'y') // Only displays if Paintballs are ordered
{
do
{
cout << "How many paintballs would you like to order? " << endl;
cout << "Note that the Paintballs are only sold in 100's, at " << pound_sign << "6 per 100 balls. " << endl;
cout << endl;
if(!(cin >> ordered_paintballs))
{
cout << "Please enter numeric values only." << endl;
cout << endl;
};
cin.clear();
cin.ignore(100,'\n');
cout << endl;
cout << endl;
} while (ordered_paintballs <= 99 || ordered_paintballs >= 10001);
};
charge = charge + (ordered_paintballs * paintball_cost); // Adds order to total charge, whether 0 or more
no_of_paintballs = no_of_paintballs + ordered_paintballs; // Adds order to paintball total
// Output - Displays collected and relevant data
system ("cls"); // Clears screen for output table
cout << "--------------------------------------------------------------------------------" << endl;
cout << "|| Your Summary ||" << endl;
cout << "--------------------------------------------------------------------------------" << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << "--------------------------------------------------------------------------------" << endl;
cout << " Name | Date | Duration | Group | Equipment | Total | Total " << endl;
cout << " | | (Hours) | Size | Hire | Paintballs | Cost " << endl;
cout << "--------------------------------------------------------------------------------" << endl;
cout << setw (12) << name << "|" << setw (12) << date << "|" << setw (10) << duration << "|" << setw (7)
<< group_size << "|" << setw (11) << equipment_hire_output << "|" << setw (12) << no_of_paintballs
<< fixed << showpoint << setprecision(2) << "|" << pound_sign << setw (8) << charge << endl;
cout << "--------------------------------------------------------------------------------" << endl;
cout << endl; // Formated into a table with <x> spaces for each value, using setw(x)
cout << endl;
cout << endl;
cout << "Please note that all free paintballs," <<endl;
cout << "and additional costs have been included in this summary." <<endl;
cout << endl;
cout << endl;
cout << endl;
// Confirmation of details, can lead to program repeat
while (confirmation != 'Y' && confirmation != 'y' && confirmation != 'N' && confirmation != 'n')
{
if (confirmation_loop_count >= 1) {cout << "Please answer Y or N." << endl;};
cout << "Are these details correct? " << endl;
cout << endl;
cin >> confirmation;
cout << endl;
cout << endl;
confirmation_loop_count++; //Adds one to loop count, to display "Please" msg.
}
// Loop question whether to repeat or end. - Only displays if details are correct
if (confirmation == 'Y' || confirmation == 'y')
{
cout << endl;
cout << endl;
cout << "Booking Confirmed - You may wish to print the details for later use." << endl;
cout << endl;
while (program_repeat != 'Y' && program_repeat != 'y' && program_repeat != 'N' && program_repeat != 'n')
{
if (program_repeat_loop_count >= 1) {cout << "Please answer Y or N." << endl;};
cout << "Do you wish to make another booking? " << endl;
cout << endl;
cin >> program_repeat;
cout << endl;
cout << endl;
program_repeat_loop_count++; //Adds one to loop count, to display "Please" msg.
}
}
// Program Loop End
if (program_repeat == 'N' || program_repeat == 'n') {repeat = 'N';};
} while (repeat != 'N'); // Forces entire program to repeat according to user choices
// Program End
cout << endl;
cout << "Thank you for booking. " << endl;
cout << endl;
system("pause");
}
It's pretty big, huh?
Blackstatik
10-12-2005, 08:11 PM
My only comment:
Keep using //comments as you have.. most people get sloppy and don't comment correctly. Don't become a sloppy coder: COMMENT COMMENT COMMENT!
Don't let your //commenting skills go away xD
Veube
10-12-2005, 08:17 PM
Looking good. Excellent formatting and nice to see plenty of comments in there.
Have you come across the switch statment yet. It is a more efficient way, processing wise, to do those endless if then statements.
Goes like this:
switch (duration) {
case 1: charge_rate = 2.60; break;
case 2: charge_rate = 2.60; break;
etc. etc.
default: charge_rate = 2.00; break;
}
The break statements means that when a match is found, execution continues to the code after the switch statment so the program doesn't have to go through EVERY case.
If you haven't already, you'll come across this eventually.[/code]
Dragonstorm
10-12-2005, 08:17 PM
hehe, Will do Black! I'm mainly using them though, because as I said..umm... somewhere... this is a Uni Coursework thing, so I need to note it to hell in order to get full marks. I've already done way more than required in the way of content, so I'm just going to go through and add more notes and then hand it in I think. still got a month and a half to edit it though if I want to!
Veube
10-12-2005, 08:20 PM
hehe, gotta love posting timing.
Dragonstorm
10-12-2005, 08:38 PM
Yeah, I did see that V, and I was supposed to use it, but I dunno exactly how to put it in, cause I dont just write "case 1" do I, cause it wouldnt know what that is!! hehe
So umm... how do I add it?
Okies, looking and I'm guessing its jsut
case = my first brackets, and statement = my second brackets.
then what about default, so I just add a random number in there, or do I set the switch subject at the start, and then say use that value?
Or is default just incase none of the others a applicable?
Oh, the reason I didnt use this in the first place, is because I dont think it saves space =\ Unless of course Case 1, 2, etc. are jsut values for Duration,etc as the only thing that changes? Rather than the whole thing still... then it would make sense! hehe, aghh! help!! =P
Dragonstorm
10-12-2005, 08:57 PM
I tried this
switch (duration)
{
1 : charge_rate = 2.60; break; // Longer durations apply different charge rates
2 : charge_rate = 2.60; break;
3 : charge_rate = 2.30; break;
4 : charge_rate = 2.30; break;
5 : charge_rate = 2.30; break;
6 : charge_rate = 2.10; break;
7 : charge_rate = 2.10; break;
8 : charge_rate = 2.00; break;
9 : charge_rate = 2.00; break;
10 : charge_rate = 2.00; break;
default : charge_rate = 2.60; break;
};
But now I get an error about unreachable code.
Dragonstorm
10-12-2005, 09:15 PM
Oh nm, I'm just stupid, I got it now, its
switch (xxx)
{
Case 1 : statement ; break;
}
Where Case 1 means in the case where xxx = 1.
Thx for the help V ^^ hehe, think thats everything I wanted to do with it for now!! =D
0bitus
10-29-2005, 01:44 PM
My apologises for bringing up an old post ... but..
As the time has come and searching the net for uni courses, what's more useful, computer game design or computer game programming? (heard a nasty rumour that there is alot of *shiver* maths in programming)
looking into getting a foot into the gaming industry ^_^ any help would be greatly useful
BakuraRyou
10-29-2005, 10:55 PM
I seriously despise Java. So, so much.
Programming sucks...learn french - far easier.
Get into admin mate... everyone needs a man to run it all!
0bitus
10-30-2005, 10:50 AM
Yeah well ive done the architecture thing for abit and im bored of that now so i dunno :/
Veube
10-30-2005, 11:18 AM
Obitus. My advice would be to choose a very general computer science course. Within the progress of that course there will be choices about with modules to go for. You can then choose the ones that bias towards games, ie. computer graphics modules, and yes the mathematics of matricies etc.
By the end of the degree you'll then have a balanced programming background with the important elements for game programming. If it turns out that game programming isn't the direction you wanted, then you've got the basic skills to go into any area.
IMO 'design' courses will only limit your own thought processes. In other words, you'll be taught how to think. But thats just my opinion. The best way to become good at designing stuff is to get as much as possible experience of the thing you want to design. So, PLAY MORE GAMES !!!
Its important to set solid foundations of raw knowledge and then you build on those with your own ways of thinking and doing.
Bak ? Despise Java ? Are you insane ? Its programming heaven !
Micros
10-30-2005, 02:09 PM
I agree, go design.
Or Fly to Japan and enter the course that Nintendo teaches over there.
(Seriously, they do teach)
0bitus
10-30-2005, 02:22 PM
http://www.londonmet.ac.uk/ug-prospectus-2006/courses/computer-visualisation-and-games.cfm that uni is offering a course which has a mixture..
year1Communications ,Introduction to Gaming and Games Engines , Introductory Visualisation , Mathematics , Programming , Software, Engineering , 3D Modelling
year2Further Programming
Programming Virtual Worlds
Representation, Photo-realism and Abstraction
VRML and OpenGL
3D Graphics
Optional modules include
Advanced Effects and Techniques
Motion and Depth Data Capture
Real-time Simulation, Fast Rendering Techniques and Algorithms
Soft Modelling, Particle Kinematics
3D Animation
year3 work placement
year4 Group Development Project
Optional modules include
Character Simulation and Artificial Intelligence
Computer-Aided Design and Manufacture
Imaging and Image Processing
Interactive Games Development
Scientific Visualisation
3D Graphics
Thing is ill have to move to london, for the week days anyway. Ive this plan that if it all fails i can just blame ryu or someone. Whats anyones views of the above course? and again apologises for hyjacking the thread.
rYugen
10-30-2005, 02:34 PM
Thing is ill have to move to london, for the week days anyway. Ive this plan that if it all fails i can just blame ryu or someone. Whats anyones views of the above course? and again apologises for hyjacking the thread.
yes just blame me... o.O
and that sounds like a good course....i just hope that you like maths and physics and stuff because thats everything for games....especially action games n stuff
BakuraRyou
10-30-2005, 03:16 PM
Bak ? Despise Java ? Are you insane ? Its programming heaven !
Mixing awt with swing does not bode well with this one!
Give me C# any day.
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.