Complete Noob Needs Help

This is a discussion on Complete Noob Needs Help within the Windows Programming forums, part of the Platform Specific Boards category; Hey, I'm a first semester student studying Game Programming. Sadly, my question has absolutely no relation to this, and is ...

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    2

    Complete Noob Needs Help

    Hey, I'm a first semester student studying Game Programming. Sadly, my question has absolutely no relation to this, and is more based around something pathetically simple (or at least what I assume is, as it's our first assignment of the semester).

    Before I get flamed to death, I'm posting this in the Windows Programming section simply because we have done VERY little ACTUAL C++ yet, and are just getting used to the Visual Studio.NET framework and Windows code. If this is better suited for the C++ (or other) forum, then I apologize in advance, and thank you for any help I can get for this.

    ------

    Basically my problem for the assignment is we're supposed to create two separate structures for a Linked List, which isn't horribly difficult in itself. My problem is I am a bit confused in how to make the lists refer to each other, this is my train of thought (although I'm pretty sure it's not right):

    Code:
    /*:::::::::::::::::::::::::::::::::::::::::::::::::
                       STRUCTURES
    :::::::::::::::::::::::::::::::::::::::::::::::::*/
    ref struct Node
    {
    	double *vin;
    	char make[255];
    	char model[255];
    	int year;
    	char colour[255];
    	ref struct TechInfo
    	{
    		int cylinder;
    		int horse;
    		int engine;
    	};
    	struct ListNode * Next;
    	struct ListNode * Prev;
    };
    However, a more pressing matter is that we're supposed to ALSO keep all the data in an array at the same time. This is where I'm really having trouble; to put it simply, I have no clue how I'm going to do this.

    For one, my method of thinking means that the array will have to hold both integers and char arrays at once.

    For two, updating specific areas of the Linked List is troublesome when doing the same with an array.

    -------

    Here's the actual assignment printout, so you can acquire a better understanding of my problem. Once again, thanks to any of you great code gurus who can help me with this. This isn't a plea for someone to do the assignment for me, just to give me a push in the right direction (or two would be nice).

    Quote Originally Posted by Assignment
    Scenario:
    You are supposed to write a program for a car manufacturing company to track their production. In order to do this you have to have a function that reads the information from keyboard and saves them both in an array (of car structure) and in a linked list.
    You are supposed to have a structure that contains VIN (Vehicle Identification number, which is a 10 digit number), Car make, Model, year and color as well as carís technical information.

    Carís technical information should be kept in another structure that is eventually going to be composed in the car structure (your car structure has a technical structure in it)
    The car technical info is consisted of No of cylinders, horse power and engine volume which are all integers).

    Obviously you have to have functions to create a menu, add car info, edit car info and delete car info to show a menu, add a car to the array and linked list, Edit carís info in both array and linked list and deleting a car from array and linked list respectively.
    I also want you to maintain your linked list a little different than last time, you are still going to have a doubly linked list but the head of the list is NOT global any more, this way I want you to pass it by reference so you get experience on that.

    You should also have to have a function that sorts both array and linked list based on VIN when its option is selected from the menu.

  2. #2
    Registered User Bajanine's Avatar
    Join Date
    Dec 2001
    Location
    The most peaks over 10,000 feet!
    Posts
    396
    So, I don't see the problem. Perhaps you need to break down the problem into smaller more manageable steps.

    For one, my method of thinking means that the array will have to hold both integers and char arrays at once.
    If I understand correctly what's wrong with using an array of structs here?

    For two, updating specific areas of the Linked List is troublesome when doing the same with an array.
    Why is this troublesome?
    Again, just break these down into smaller steps write your function to handle the linked list and then write a function to handle the array.
    It sounds like you already have the double linked list mostly done:
    I also want you to maintain your linked list a little different than last time, you are still going to have a doubly linked list...
    Try writing some code and when you get stuck come on back!

    If you have already done a double linked list I don't get how you could be confused on an array?


    edit/
    and saves them both in an array (of car structure) and in a linked list.
    Last edited by Bajanine; 01-20-2007 at 11:15 PM.
    Favorite Quote:

    >For that reason someone invented C++.
    BLASPHEMY! Begone from my C board, you foul lover of objects, before the gods of C cast you into the void as punishment for your weakness! There is no penance for saying such things in my presence. You are henceforth excommunicated. Never return to this house, filthy heretic!



  3. #3
    Registered User
    Join Date
    Jan 2007
    Posts
    2
    The problem is that we HAVEN'T done a Linked List before, we only have a few in-class examples to work on, sadly. They compressed the course recently and as such I'm personally at a loss.

    So basically, this is my error filled code which I don't even understand:

    Code:
    /*:::::::::::::::::::::::::::::::::::::::::::::::::
                       STRUCTURES
    :::::::::::::::::::::::::::::::::::::::::::::::::*/
    struct CarStructure
    {
    	double vin;
    	char *make;
    	char *model;
    	int year;
    	char *colour;
    	struct TechInfo
    	{
    		int cylinder;
    		int horse;
    		int engine;
    	};
    	struct ListNode *Next;
    	struct ListNode *Prev;
    };
    typedef struct CarStructure CarNode;
    typedef CarNode *CarNodePtr;
    
    /*:::::::::::::::::::::::::::::::::::::::::::::::::
                        ARRAYS
    :::::::::::::::::::::::::::::::::::::::::::::::::*/
    
    
    
    /*:::::::::::::::::::::::::::::::::::::::::::::::::
                      PROTOTYPES
    :::::::::::::::::::::::::::::::::::::::::::::::::*/
    void ViewCarInfo(CarNodePtr*, double, char*, char*, int, char*, int, int, int);
    void AddCarInfo(CarNodePtr*, double, char*, char*, int, char*, int, int, int);
    void EditCarInfo(CarNodePtr*, double, char*, char*, int, char*, int, int, int);
    void DeleteCarInfo(CarNodePtr*, double, char*, char*, int, char*, int, int, int);
    
    /*:::::::::::::::::::::::::::::::::::::::::::::::::
                          MAIN
    :::::::::::::::::::::::::::::::::::::::::::::::::*/
    int main()
    {
    	CarNode * Start;
    	CarNode * Newnode;
    	int choice;
    	while(choice != 5)
    	{
    		Console::WriteLine(":::Welcome to the Car Info Program:::");
    		Console::WriteLine("Please Select an Option:");
    		Console::WriteLine(" - 1 - View Car Info");
    		Console::WriteLine(" - 2 - Add Car Info");
    		Console::WriteLine(" - 3 - Edit Car Info");
    		Console::WriteLine(" - 4 - Delete Car Info");
    		Console::WriteLine(" - 5 - End Program");
    		choice = Convert::ToInt32(Console::ReadLine());
    		Console::WriteLine("");
    
    		switch(choice)
    		{
    		case 1:
    			void ViewCarInfo();
    			break;
    		case 2:
    			void AddCarInfo();
    			break;
    		case 3:
    			void EditCarInfo();
    			break;
    		case 4:
    			void DeleteCarInfo();
    			break;
    		default:
    			Console::WriteLine("ERROR: Pitiful Human, This Number IS NOT An Option!");
    			Console::WriteLine("");
    			break;
    		}
    	}
    }
    
    /*:::::::::::::::::::::::::::::::::::::::::::::::::
                      VIEWCARINFO
    :::::::::::::::::::::::::::::::::::::::::::::::::*/
    void ViewCarInfo(CarNodePtr *ViewPtr, double vin, char *make, char *model, int year, char *colour, int cylinder, int horse, int engine)
    {
    	if (Start == NULL)
    	{
    		Console::WriteLine("ERROR: Please Enter a Car First.");
    	}
    	else
    	{
    		struct CarNode * Current;
    		Current = Start;
    		while (Current -> Next != NULL)
    		{
    			Console::Write("VIN: ");
    			Console::WriteLine(Current -> vin);
    			Console::Write("Make: ");
    			Console::WriteLine(Current -> *make);
    			Console::Write("Model: ");
    			Console::WriteLine(Current -> *model);
    			Console::Write("Year: ");
    			Console::WriteLine(Current -> year);
    			Console::Write("Colour: ");
    			Console::WriteLine(Current -> *colour);
    			Console::Write("Cylinders: ");
    			Console::WriteLine(Current -> cylinder);
    			Console::Write("Horsepower: ");
    			Console::WriteLine(Current -> horse);
    			Console::Write("Engine: ");
    			Console::WriteLine(Current -> engine);
    			Current = Current -> Next;
    			Console::WriteLine();
    		}
    		Console::Write("VIN: ");
    		Console::WriteLine(Current -> vin);
    		Console::Write("Make: ");
    		Console::WriteLine(Current -> *make);
    		Console::Write("Model: ");
    		Console::WriteLine(Current -> *model);
    		Console::Write("Year: ");
    		Console::WriteLine(Current -> year);
    		Console::Write("Colour: ");
    		Console::WriteLine(Current -> *colour);
    		Console::Write("Cylinders: ");
    		Console::WriteLine(Current -> cylinder);
    		Console::Write("Horsepower: ");
    		Console::WriteLine(Current -> horse);
    		Console::Write("Engine: ");
    		Console::WriteLine(Current -> engine);
    	}
    	Console::WriteLine();
    }
    Currently me and about 4 other people are sitting down trying to figure this out. Yes, it's sad we can't even get this, and we realize it - hense why we need help.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Complete C noob...and completely stuck lol
    By JST212 in forum C Programming
    Replies: 6
    Last Post: 03-02-2008, 10:54 AM
  2. How to complete program. Any probs now?
    By stehigs321 in forum C Programming
    Replies: 7
    Last Post: 11-19-2003, 04:03 PM
  3. .ico (COMPLETE NOOB)
    By Rage7531 in forum Windows Programming
    Replies: 2
    Last Post: 05-13-2002, 06:07 PM
  4. Doom Lord engine complete!
    By Leeman_s in forum Game Programming
    Replies: 8
    Last Post: 05-12-2002, 01:44 AM
  5. doom lord engine complete!
    By Leeman_s in forum C++ Programming
    Replies: 4
    Last Post: 04-25-2002, 09:41 PM

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