English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Write a fully-documented class named RequestQueue that must be derived as a subclass of Vector from the Java API. You should provide a constructor and the standard methods enqueue(), dequeue(), size(), and isEmpty() as were discussed in lecture.

DOES that mean that I gotta have a vector object as a private member and make that object work as a queue using functions from the vector class, but at the end I will have my deque, enque, size, empty......

is my thought right or not?

and on the header of the class I would have something like:

public class RequestQueue extends Vector
{
..............
}
if I have extends....I don't see the point because I could simply put this before the class header...

import java.util.*;

help please

2007-10-23 21:43:03 · 2 answers · asked by Angel 1 in Computers & Internet Programming & Design

2 answers

No because you are not going to provide a wrapper for Vector but rather your own class (RequestQueue) that will inherit from Vector and have your own additional functionality.

The point is that you will get all the Vector implementation for free via super.

Take a look at the following - it should give you the idea but there's a lot more to it - constructors, error handling, generics to make it type-safe if you are queuing a particular type...







_

2007-10-23 21:53:07 · answer #1 · answered by SadButTrue 4 · 0 0

No they are not saying you should create a Vector internally, in fact what you have ... extends Vector makes the thing sorta Vector already with accessible and capable to all that Vector should have and that is exactly what's being asked, this basic OOP concept is kinda difficult to explain to a newbie but you got most of it already.

2007-10-23 21:57:51 · answer #2 · answered by Andy T 7 · 0 0

fedest.com, questions and answers