Help with c++ coding

This is a discussion on Help with c++ coding within the C++ Programming forums, part of the General Programming Boards category; We want to put in our arckives this information about the players , can we get help how to make ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    25

    Help with c++ coding

    We want to put in our arckives this information about the players , can we get help how to make a c++ code. We want it to be as what we wrote below. You can see our startings code in the end of articl but we couldnīt more.


    1. Programet start with writing the name of the team

    Write the name of the team: Kotoko

    2. Menu it will shows with two options , add a new player or show all the players.

    Teams namn: Kotoko
    (1) Add new player.
    (2) Show all the players.

    (0) Close

    Choose: 1

    Teams namn: Kotoko

    Add a player nr 1

    First name: John // You write all this information
    Last name: Phillip
    Age: 24
    Position: Forward

    *When you put the player programet go to the menu

    Teams namn: Kotoko

    (1) Add new player.
    (2) Show all the players.

    (0) Close

    Choose: 2 // to show all the players

    Teams namn: Kotoko

    1. Phillip, John 37 Forward
    2. Ritchard, Jan 26 Back
    3. Nils , Hans 32 Goalkeeper

    Click en key to go to menu

    Teams namn: Kotoko

    (1) Add new player.
    (2) Show all the players

    (0) Close

    Choose: 0


    Code:
     
    #include <iostream>
    #include <iomanip>
    using namespace std;	// 
    
    int main ()				// 
    {
    
    	int tal1;		// 
    	int tal2;		// 
    	int tal3;		// 
    	cout << "\nTEAMPROGRAMMET" << endl;		// 
    	cout << "\nWrite the name of the team" << endl;				// 
    	cin >> tal2;
    	cout << '\n';
    	cout << "(1) Add a new player." << endl;			// 
    	cout << "(2) Show all the players." << endl;
    	cout << '\n';
    	cout << "Choose: \n\n"; 
    	int player;
    	cin >> player;
    	if (player == 1)
    {
    	cout << "TEAMPROGRAMMET: kotoko" <<  endl;
    	cout << "Add in new player nr 1" << endl;
    	
    }
    
    	return 0;			// 
    }

  2. #2
    Registered User
    Join Date
    Jun 2002
    Posts
    230

    Wink

    Well you want to store the players information. You have options here. My best advice would be create a structure for these players

    Code:
    struct Player{
       string firstName;
       string lastName;
       string position;
       int age;
    };

    and then you can create a vector of pointers to hold these structs.

    vector <Player*> p;

    Not sure how much you know about vectors, structures and pointers. Im pretty sure there is a tutorial on this at this website.
    Im also sure there might be easier ways to do this, but tell us exactly what do you need help with? is it storing the players?
    C++ Rules!!!!
    ------------
    Microsoft Visual Studio .NET Enterprise

  3. #3
    Registered User
    Join Date
    Sep 2005
    Posts
    25
    Hi
    Thank you for your replying
    Iam really need a program for our fotballs teams basket , fotball , vollyball .To start the code with writing the name of one team , exemple Fotball. When i wrote it will come up a menu list with two options:
    The team is: Fotball
    1) Add a new player
    (2) Show all the players
    if i choose (1) it will give me:
    The team is : Fotball
    Add in new player nr (1).
    Here i have to write the player first name , last name , age and position (That you suggesed). When i finished this one it will go back automatic to the menu. i will choose this time nr (2) which it is going to show the list of the player , (i wrote three players) on my first post. When all the players seen , i want to click one key to go back to the menu again. If i choose 0 any time i will close the code. Hope you understand and want to help us. Thanks

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    You don't need all those empty comments:
    Code:
    //
    Do you know how to use while loops?
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  5. #5
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    Just make one big menu where you can pick football, basket ball, etc. Then you pick one and it opens a sport specific file and reads the info from it, this way you can close the program and not lose the data. Then adding a new player you write to the file, for all file operations you could use fstream.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  6. #6
    Registered User
    Join Date
    Sep 2005
    Posts
    25
    Please iam not so good in programing , i have tried all you wrote but i couldnīt and i have spent mutch time to fix this code , i hope to get help from you. Thanks

  7. #7
    Information Crocodile
    Join Date
    Dec 2004
    Posts
    204
    What about go to the tut section of the site ??

  8. #8
    Registered User
    Join Date
    Jun 2002
    Posts
    230
    If you dont know alot about programming this project might be alittle difficult to jump into. Try first reading some tutorials looking into case statements loops and as someone suggested file reading and writing to store your data externally. After you learn all that then you can put it together and make this program.
    C++ Rules!!!!
    ------------
    Microsoft Visual Studio .NET Enterprise

  9. #9
    Registered User
    Join Date
    Sep 2005
    Posts
    25
    I agree with you abot what you wrote but in this case we are in the finishing of our archives and evrey thing have to be ready tomorow for to show that with other work to the committe of the team , otherwise i could wait until i learn me . Please do to me this time and i promise to do what you said.

  10. #10
    Registered User
    Join Date
    Sep 2005
    Posts
    25
    God bless you , iam waiting your help

  11. #11
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    Here I wrote up a program that does what you want(or what I think you want), it stores, reads, and can remove players on different teams. It requires minimal change on your part, I even commented on the parts that need to be changed. The only change you need to make is to the name of the teams, I just put football,soccer,hockey,and basketball since those are sports teams. You can just change it to the name of the team, like kotoko, and it will work. Did you want it so you type the team's name and it retrieves the data or you can create a team if it doesn't exist?? Also, I know my code is a little messy and uncommented, it's because I was busy today and thought you needed it for tomorrow so I just made sure it was done by tonight. There may have been an easier way to do this but I did it the way I like to, with vectors. The code was written on Dev-C++ 4.9.9.2 compiler so it should compile on most compilers. Attached:
    Attached Files Attached Files
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  12. #12
    Registered User
    Join Date
    Sep 2005
    Posts
    25
    I really thanks you from my heard. I have only one question:
    When the code start with Choose a sport , i want after this it come: Write your team:
    And enstead of choosing nr 1 i want to write fotball .
    The last you forgot to but 0 if i want to close the code any time .

  13. #13
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    So something more like this:
    Attached Files Attached Files
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  14. #14
    Registered User
    Join Date
    Sep 2005
    Posts
    25
    Evrything is perfect now , only instead of type exit to quit i want to write type 0 to quit.
    *Ypu forgot to put (Position) with list of:
    First name
    Last name
    Age
    Position
    I am really appricating you help. You are a good man. Thanks
    Last edited by sd03eee; 10-24-2005 at 05:54 PM.

  15. #15
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    Here:
    Attached Files Attached Files
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 03-20-2009, 05:22 PM
  2. Coding Guideline ....!!
    By imfeelingfortun in forum Tech Board
    Replies: 8
    Last Post: 10-08-2006, 07:09 AM
  3. Before Coding
    By cyberCLoWn in forum C++ Programming
    Replies: 16
    Last Post: 12-15-2003, 01:26 AM
  4. Coding Contest....
    By Koshare in forum A Brief History of Cprogramming.com
    Replies: 46
    Last Post: 10-14-2001, 04:32 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21