Alright I'm new to Java and I'm in the middle of doing my java project. I
have a super class called SFactory that has 2 protected Queues named q1 and
q2. I was asked to create a class called PlateFactory that will extend
SPlateFactory.
The Factory constructor:
public Factory(int n)
/* builds two identical queues containing n randomly-
generated plates. The variables q1 and q2 (inherited
from SPlateFactory) may be initialized and accessed
directly in this constructor. */
This is what I did:
public Factory(int n) {
for (int i = 0; i < n;i++){
Plate p = new Plate();
q1.enqueue(p);
q2.enqueue(p.getCopy());
}
}
This is fine except that I need to first actually create the
2 new queues (empty) that q1 and q2 will reference.
How do i do that?
Thanks
Jazz
Anton Spaans - 31 Oct 2003 15:52 GMT
What about these extra two lines (providing that your superclass SFactory
has not yet created these two queues....)?:
public Factory(int n) {
q1 = new Queue();
q2 = new Queue();
for (int i = 0; i < n;i++){
Plate p = new Plate();
q1.enqueue(p);
q2.enqueue(p.getCopy());
}
}
-- Anton.
> Alright I'm new to Java and I'm in the middle of doing my java project. I
> have a super class called SFactory that has 2 protected Queues named q1 and
[quoted text clipped - 27 lines]
>
> Jazz