Alright guys I need MAJOR help..!!!!!!!!!!!

I have looked at classes and kinda get some what of it well and I have looked at the class tutorial but still confused but its the linear linked list that I am confused about because I have a huge assignment to do and not sure where to start..


But to sum up my program assignment I need to create a program that keeps track of of wineries profit. More specifically keep track of name, location, number of acres, and success rating. All the directions are below for this assignment and need major help its due soon really want to do well. I have been given the files from our teacher and I will post it below with a comments annd its alot of files but I will post them below. any major help will be awesome


CS260 Lab 1

Instructions

You have noticed a large number of wineries appearing around the country side, and you are interested in finding out how profitable they are becoming. You have decided to write a program to begin tracking their progress. You want to keep track of at least:

the name of the winery
the general location (e.g. in Banks)
the number of acres of vineyards associated with the winery
overall success rating
You have decided to create a linear linked list of this information, sorted by the winery's name. But, since you are interested in determining how successful they are, you also want the information organized by rating (from best to worst!). Therefore, you have decided to create a doubly threaded linear linked list. Unlike what we did in CS162, every node will have two pointers (one is a next pointer sorted by name, and another is a next pointer for the rating).

In other words, you will have only one set of nodes, with two threads going through those nodes. One thread goes through them by name, the other goes through them by rating.

Do not make two separate lists (i.e. two separate sets of nodes), one ordered by name and the other by rating. Doing this will result in a serious loss of points.

Implementation Requirements

Create a Winery class to model the winery object.
Make sure you encapsulate the the data, i.e. put data members in the private section of the class.
Use char * to model strings instead of string.
Create a List class to manage the wineries. The List class needs to be implemented using a “doubly threaded” linear linked list:
struct Node
{
Node(const Winery& winery); // constructor
Winery item;
Node *nextByName;
Node *nextByRating;
};

class List
{
...
private:
Node *headByName;
Node *headByRating;
};
The List class needs to provide operations to:
add a winery
remove a winery
display all the wineries sorted by their ratings
display all the wineries sorted by their names
search for a winery by name



Strings

For storing and printing strings, you should use C strings. Your code should #include <cstring> and use the functions defined in that header, such as:

int strlen(char *str)
// given a string pointer, returns the length of that string,
// which does not include the terminating '\0' character
void strcpy(char *dst, char *src)
// copies the characters in src to dst,
// including the terminating '\0' character
Using strcpy will cause a compiler warning. You will need to get rid of this warning by adding one of the following as the first line of .cpp files that use strcpy:

#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable:4996)
Printed Output

Your code’s printed output should be identical to the contents of lab1output.txt, a file that’s provided as part of this lab. “Identical” means the Linux utility diff will find no differences between your code’s output and lab1output.txt, when called with flags: -w -B. This means that the sequence of non-whitespace characters in your output has to be identical, but that differences in whitespace will be ignored. You are still required to produce output that lines up with itself properly, as lab1output.txt does.

Memory Leaks

Your code is required to run in Microsoft Visual C++ 2010 Express without memory leaks. The starter code for this project includes support for memory leak detection in VC++ 2010.

Initialization Lists

The constructors in your code should use initialization lists to the maximum extent possible. Points will be deducted where this is not done.

Here is a class definition:

class SomeClass
{
...

private:
int dataMember1;
int dataMember2;
}
Here is a constructor for this class that does not use initialization lists:

SomeClass::SomeClass(int dataMember1, int dataMember2)
{
this->dataMember1 = dataMember1;
this->dataMember2 = dataMember2;
}
And here is one that does use initialization lists:

SomeClass::SomeClass(int dataMember1, int dataMember2) :
dataMember1(dataMember1),
dataMember2(dataMember2)
{
}
An initialization list consists of comma-separated items between the : and the {. Each of these items is of the form:

dataMemberName(value)
Each item sets the named data member to the value in the parentheses. In the SomeClass constructor above, each of the two initialization list items sets its data member to the constructor argument named inside the parentheses. This is weird-looking syntax, but it is standard usage in the culture of C++.




Last edited on
this is the lab 1 driver.cpp


// make NO CHANGES to this file

#pragma warning(disable:4996) // disable warnings about use of strcpy()

#include "memoryleakdetect.h" // this must be the first #include in each of your .cpp files
#include <iostream>
#include "winery.h"
#include "list.h"

using namespace std;

static List *wineries;

// Ask list to insert a winery into the doubly-threaded linked list.
// Note what this function does with memory, which has implications for
// how you will (and will not) be able to use the winery instance that's
// passed to wineries->insert.
static void insertWinery(char *name, char *location, int acres, int rating)
{
Winery *w;
char *nm = new char[strlen(name) + 1];
char *loc = new char[strlen(location) + 1];

strcpy(nm, name);
strcpy(loc, location);
w = new Winery(nm, loc, acres, rating);
wineries->insert(*w);
delete[] nm;
delete[] loc;
delete w;
}

// Display all wineries in the list,
// first in order by name, then in order by rating.
static void displayWineries(ostream& out)
{
out << "+++ list by name" << endl;
wineries->displayByName(out);
out << endl << "+++ list by rating" << endl;
wineries->displayByRating(out);
}

int main(int argc, char **argv)
{
Winery *wPtr;

cout << "CS260 - Lab1 - " << Winery::YOUR_NAME << endl << endl;

wineries = new List();

insertWinery("Lopez Island Vineyard", "San Juan Islands", 7, 95);
insertWinery("Gallo", "Napa Valley", 200, 25);
insertWinery("Cooper Mountain", "Willamette Valley", 100, 47);
insertWinery("Duck Pond Cellars", "Willamette Valley", 845, 70);
insertWinery("Del Rio", "Bear Creek Valley", 200, 37);
insertWinery("Weisinger's of Ashland", "Bear Creek Valley", 6, 83);
insertWinery("LongSword", "Applegate Valley", 16, 85);

displayWineries(cout);

cout << endl << ">>> removing Cooper Mountain" << endl << endl;
wineries->remove("Cooper Mountain");

displayWineries(cout);

cout << endl << ">>> inserting San Juan Vineyards" << endl << endl;
insertWinery("San Juan Vineyards", "San Juan Islands", 20, 90);

displayWineries(cout);

cout << endl << ">>> search for \"Gallo\"" << endl << endl;
wPtr = wineries->find("Gallo");
if (wPtr != 0)
cout << wPtr;
else
cout << "not found" << endl;

cout << endl << ">>> search for \"No Such\"" << endl << endl;
wPtr = wineries->find("No Such");
if (wPtr != 0)
cout << wPtr;
else
cout << "not found" << endl;

cout << endl;

delete wineries;

// report on memory leaks in the Output Window
#ifdef _DEBUG
if (argc == 2) {
_CrtSetReportMode( _CRT_WARN , _CRTDBG_MODE_FILE );
_CrtSetReportFile( _CRT_WARN , _CRTDBG_FILE_STDERR );
}
_CrtDumpMemoryLeaks();
#endif

return 0;
}
this is the list.cpp

#include "memoryleakdetect.h" // this must be the first #include in each of your .cpp files
#include <iostream>
#include "list.h"

List::List()
{

// your code here, or in this constructor's initialization list
}

List::~List()
{
// your code here
}

/*
You will need to uncomment this constructor and write the code for it.

List::Node::Node(const Winery& winery) :
// your initialization list here
{
// your code here
}
*/

void List::displayByName(ostream& out) const
{
// your code here
}

void List::displayByRating(ostream& out) const
{
// your code here
}

void List::insert(const Winery& winery)
{
// your code here
}

Winery * const List::find(const char * const name) const
{
// your code here, return the appropriate value
return 0;
}

bool List::remove(const char * const name)
{
// your code here, return the appropriate value
return false;
}
this is list.h


// make NO CHANGES to this file

#pragma once // include this .h file file only once

#include <ostream>
#include "winery.h"

using namespace std;

class List
{
public:
List(void); // constructor
virtual ~List(void); // destructor

// Print out the wineries in alphabetical order by name,
// by calling winery's operator<< for each winery.
void displayByName(ostream& out) const;

// Print out the wineries from highest to lowest rating,
// by calling winery's operator<< for each winery.
void displayByRating(ostream& out) const;

// Insert a winery into both the names and ratings threads.
// The names thread should be in alphabetical order by name.
// The ratings thread should be in order from highest rating
// to lowest rating.
void insert(const Winery& winery);

// Return a const pointer to the winery instance it finds in
// the list, or 0 if it didn't find a winery with that name.
// Because the pointer is declared const, there is no danger
// that find's caller will be able to use the returned pointer
// to change the instance of winery.
Winery * const find(const char * const name) const;

// Remove the winery with the specified name from both the name
// thread and the ratings thread. Returns true if it found and
// removed the winery, false if it did not find the winery.
bool remove(const char * const name);

private:
// defines each node in the doubly-threaded linked list.
struct Node
{
Node(const Winery& winery); // constructor
Winery item; // an instance of winery
// (NOT a pointer to an instance)
Node *nextByName; // next node in the name thread
Node *nextByRating; // next node in the rating thread
};

Node *headByName; // first node in the name thread
Node *headByRating; // first node in the rating thread
};
dont know if this is important but this is the

memory leak detection

// make NO CHANGES to this file

#pragma once // include this .h file file only once

// enable Visual C++ memory leak checking
#ifdef _DEBUG
#include <ostream>
#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
#define new DEBUG_NEW
#endif
this is the winery.cpp


#include "memoryleakdetect.h" // this must be the first #include in each of your .cpp files
#include "winery.h"

using namespace std;

// change the value of this variable to be your own name instead of "I. Forgot"
const char Winery::YOUR_NAME[] = "I. Forgot";

Winery::Winery(const char * const name, const char * const location, const int acres, const int rating)
{
// your code here, or in this constructor's initialization list
}

Winery::~Winery()
{
// your code here
}

void Winery::displayColumnHeadings(ostream& out)
{
// print out column headings for lists of wineries, as specified by lab1output.txt
}

ostream& operator<<(ostream& out, Winery *w)
{
// print out a winery, as specified by lab1output.txt
return out;
}

and lastly this is the winery.h


// make NO CHANGES to this file

#pragma once // include this .h file file only once

#include <ostream>

class Winery
{
public:
static const char YOUR_NAME[]; // used for printing out programmer's name

Winery(const char * const name, const char * const location, const int acres, const int rating);
virtual ~Winery(void);

// complete implementations for the following 4 functions, nothing needed in the .cpp file
const char * const getName() const { return name; }
const char * const getLocation() const { return location; }
const int getAcres() const { return acres; }
const int getRating() const { return rating; }

// print out column headings for lists of wineries, as specified by lab1output.txt
static void displayColumnHeadings(std::ostream& out);

// print out a winery, as specified by lab1output.txt
friend std::ostream& operator<<(std::ostream& out, Winery *w);

private:
char *name;
char *location;
int acres;
int rating;
};
You really expect us to read all of that? Not only do you not post it in [code] tags, but you don't even tell us what you're having trouble with. We're not here to do your homework for you... work on it yourself and come to us when you run into an error.
Last edited on
Hey packet pirate no no I wasn't meaning for you guys to do the homework I just need help on understanding classes and linear linked list from your guys view for me I understand concepts when it I hear from someone who understands it rather then reading from the book it sometimes confuses me. I just put all of these information cuz that's just the directions and files for this assignment. I thought I better post all I could so I can get better input not just. answers just help. I am sorry if it seemed like that I just need a direction. Hmm a starting point could be based from the files above there's already the constructor in the .h file for winery but what I just don't know how to go about what to put in there considering the parameters that's in the winery.cop file for winery. Again I am sorry I just need help not for you to do my homework
I understand that, but what have you done to try and solve the problem yourself? Maybe if you tell us what you're having trouble understanding, exactly, we can help you better.
Right. It's really difficult to help when people just post a problem and say "help me".

It's much easier when they have specific questions that we can answer.

So ask some questions.
Topic archived. No new replies allowed.