Thread: Functions and Linked lists problem

  1. #1
    Registered User
    Join Date
    Sep 2012
    Posts
    21

    Functions and Linked lists problem

    Hello everyone,
    I am making a Monopoly type game using linked lists and functions.
    Basically the linked lists will store each user, number of houses, and number of hotels, and properties.
    This is what we were given to work with.

    Code:
    struct property {
        char name[30];
        int user;
        int num_houses;
        int num_hotels;
        struct property * next;
    };
    We also need functions for buying, selling, and improving properties.

    I have all the small things done with my code but I really need some guidance on linked lists and functions.
    Here is my code right now

    Code:
    #include <stdio.h>
    
    
    #define HOUSE  25
    #define HOTEL  50
    #define PROPERTY  100
    
    
    struct property {
        char name[30];
        int user;
        int num_houses;
        int num_hotels;
        struct property * next;
    };
    
    
    
    
    //Buy function (search for name and add to linked list)
    //Improve function (Add hotel or house, add to linked list)
    //Sell function (Print amount property is worth + hotels and houses, remove property from linked list)
    
    
    int main () {
        int num_players, selection, count;
    
    
    printf("Welcome to Monopoly!\n");
    printf("How many players will there be?\n");
    scanf("%d", &num_players);
    
    
    printf("Enjoy your game!\n");
    count = 1;
    
    
    do {
    if (selection == 5)
            count ++;
        if (count > num_players)
            count = 1;
    
    
    printf("Player %d what would you like to do?\n", count);
    
    
        printf("\t1-Buy Property\n");
        printf("\t2-Improve Property\n");
        printf("\t3-Sell Property\n");
        printf("\t4-View Properties\n");
        printf("\t5-End Turn\n");
        printf("\t6-End Game\n");
        scanf("%d", &selection);
    
    
    
    
    
    
    //Selection Results
    
    
    }
        while (selection != 6);
        //if (selection == 6)
            //End game function
    
    
    
    
    return 0;
    
    
    }

    any nudges would be greatly appreciated

    Edit: I know a little about how to use functions (still very shaky, trying to read as much as I can to understand better) but I am completely lost when it comes to linked lists
    Last edited by krazzyjman; 09-29-2012 at 02:16 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Double Linked Dynamic Lists Vs Unrolled Linked Lists
    By lantzvillian in forum C Programming
    Replies: 6
    Last Post: 02-14-2012, 01:07 PM
  2. Problem with linked lists
    By Falsdor in forum C Programming
    Replies: 4
    Last Post: 05-15-2011, 11:17 PM
  3. Replies: 9
    Last Post: 01-03-2009, 03:48 PM
  4. Linked Lists problem
    By needhelpbad in forum C Programming
    Replies: 46
    Last Post: 12-17-2008, 01:12 PM
  5. linked lists problem
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 06-17-2002, 10:55 AM