h/with c++ a/ment

hey guys, i need help with an assignment i have to do.

its made up of 3 differant tasks. i can seem to get it right!

your help would be greatly appreciated!

my email is gremlin_shesh@hotmail.com

task1
arrays, classes, inheritance, polymorphism, exception handling.

a) design, implement and document a library borrowing system. a library maybe represented as an array of objects of class book.
A librarian must be able to:

-add a new book to the library
-remove a book from the library
-search for a specific book
-list books on a given subject or author in an alphabetical order.

b) there is assumed to be a base class library. there will be three derived classes which are named: books, journals and videos. the previous operations of the earlier problem (book class implemented in section a) are to be made available to all the derived classes. it is left to your judgement as to what additional operations are appropriate in each case. obviously, more information may be obtained from the library.

task2
class, inheritance, generics, code reusability

A novice programmer has provided the following code for the stack class:

Class stack
{

private:
int st [100];
int top;

public:
stack() { top=-1;}
void push(int var) { st[++top]=var; }
int pop() { return st[top--]; }

};

a) trace the stack class code provided above to demonstrate that the stack is carrying out its function as long as the array bound is not violated.

b) it is obvious that is a class if full, an item cannot be placed in a stack, similarly, if a stack is empty, an item cannot be removed from a stack. use the inheritance feature of c++ to amend the code given above so that these two conditions are met.

c) as the above code shows, the given stack can only handle integers. use the generic feature of c++ to create a parameterized stack which can be generated and used for any required type.

task 3
stack data structure, class, exceptional handling, templates

a) use a class to implement a stack. this stack uses an interger array and provides the appropriate stack methods such as:
push(n)
pop()
stack_empty()
stack_full
top()

b) at a later stage there is need for:
-a stack to handle strings
- a stack to handle objects belonging to the class rectangle
- a stack to handle objects belonging to the class stack implemented above.

use the template feature of c++ to provide the required stacks listed above.

THATS IT GUYS.... PLZ PLZ HELP ME OUT.

gremlin_shesh@hotmail.com

thankyou in advance.

That's a pretty hefty assignment. Well, as you say, we will help you out but we will not write your code for you. This is an assignment for you where you should already have been taught this stuff and should now apply to get a better grasp on it, or you have been told to do this so you will learn these things. If anybody did the assignment for you, what would you learn? Not a thing =/

So, make a plan (maybe some pseudocode) and then start coding. If there is something specific you cannot understand or are stumped on how to do something, then ask here, post whatever code is relevant to your question, and you will get an answer.

I have my own homework to do =)
For the third assignment, see:
http://www.informit.com/content/images/020163371x/supplements/Exception_Handling_Article.html

This is quite a non-trivial task. If you want to provide an out of the ordinary solution, I recommend reading the article and asking the one giving you the assignment if he was aware of it. This stack example is discussed in detail in "Exceptional C++" by Herb Sutter, pp. 25-60. Another reference I can recommend.

Edit: If you use either reference, state that you did. (a) it is not forbidden, (b) it doesn't make you look stuped or something, on the contrary, taking the knowledge from others is a Good Thing, (c) if you don't and your teacher knows about the ressources, you're screwed. (I know, I was (a) in school and (b) was a tutor for a course at university, and trust me, one *knows* if someone wrote the code he hands in himself)
Last edited on
thanks for the link exception. actually, we didnt had a teacher for half the semester and when we got one, he got into an accident. i can resit the exam, but then i wud have to pay alot more fee's.

thanks
Of course, the std::stack is just an adapter for the std::deque. You are not allowed to do it the same way, are you? Some of the problems discussed in the link are handled in the deque, so you don't need to worry that much.
plz guys! i need your help!!!!

ne help with task2?

i got through with the rest.

thanks
Topic archived. No new replies allowed.