0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
Relax and destress yourself. This is very simple. You can do it, but not while your head is full of stress and "I can't do this".

The simple fact is that I can't even give you the answer directly because I also don't have any definitive information on the UnsortedType class. Are you sure you really have absolutely nothing on this? If that's the case then I don't see how your tutor can reasonably expect you to complete the assignment and you should IMMEDIATELY raise this issue with him. This assignment is dependent on knowledge of the UnsortedType class and is impossible if that knowledge is nonexistent.

What you would be looking for is some code which starts with "class UnsortedType" and that lists the member variables and functions, including info, length, possibly MAX, maybe one or more UnsortedType constructors, a destructor, maybe RetrieveItem() and other functions.

Earlier you posted some code that started "void UnsortedType::RetrieveItem". Where did you get that from? Did you just make it up; did you hook up /dev/random to a C++ keyword generator, or did you get it from somewhere, e.g. unsortedtype.cpp/unsortedtype.h?

If the function you have to write has the prototype "ItemType ReturnLastItem();" then the outline of the function must be something like:
Code:
ItemType UnsortedType::ReturnLastItem()
{
  // some processing needed?
  return /* what do we return? */ ;
}
If any processing is needed it will be to determine which entry is last in the list. At a guess I'd say that was length-1, but nobody it seems knows what length is.
We return something; what will that be, do you think? You can narrow down the possibilities if you have the class definition, because you'd be looking for something of type ItemType, or maybe an array of them.
0
elsa87's Avatar, Join Date: Oct 2008
Go4Expert Member
mmmmmmmm
what inforamtion do u need on the UnsortedType class? what difference would it make? can't we just assume we are making a class from scratch?
last try and im giving up lol
we have an unsorted list with length that we dont know
so the last item we are going to retrieve is length-1, right?(by the way..ADT means linked list???)
and if we are going to just retrive the last item then why do we need processing?
we will just return(item located in the end of the list)
bravooooo lol but i have no idea how to implement it loooool
Quote:
"void UnsortedType::RetrieveItem". Where did you get that from?
i was just copying and pasting from my lecture notes to come up with some solution
0
AmNoob's Avatar, Join Date: Nov 2008
Newbie Member
Dont you get it???

its a MEMBER function which means its in the class Unsorted

Class UnsortedType{
.......
.....
.......
......
ItemType ReturnLastItem();
.....
private:
.....
....
}

then you write that function they told you already lol

ItemType UnsortedType::ReturnItemType()
{
return info[length];
}

**I just want to know how to write the ReturnItemType the result of that to an OutputFile text, and reading the list from a ready input file text.

for example:
input file contains: 10 7 98 54 13 66 4
how to let the program read the values of the list in the input file which is already there and then let the program create an outputfile txt with the result of ReturnLastItem()... how??????