[Bluej-discuss] Book: Excercise 1.17

Matthew Brandt mattchief at gmail.com
Mon Aug 7 14:59:06 BST 2006


Bryan,
Thanks! I had made the mistake of declaring my Student class as Private.
Simply switching it to Public remedied my predictament. Thank you for taking
the time to help me debug. I've just started using the "Objects First with
Java: A Practical Introduction using BlueJ," by David J. Barnes & Michael
Kölling. Some of the examples early examples (chapter 1 &2) from the book
(the downloadable book projects <http://www.bluej.org/objects-first/>)
aren't compiling as easily as I suspect they should.

Cheers,
Matt

On 8/5/06, Bryan J. Higgs <bhiggs at rivier.edu> wrote:
>
>  Matthew --
>
> The line:
>
> private List<Student> students;
>
> says that you are declaring a field in your LabClass called 'students',
> which is of type 'List of Students'.
> A List is one type of 'container' class, which can contain zero or more
> objects.
> A List of Students may only contain objects of type Student (which must be
> the name of a class).
> If you don't have a class called Student in your program, then your
> program won't compile, because the compiler won't know what 'Student' means.
>
> You could write a simple student class something like:
>
> public class Student
> {
>     private String name;
>
>     public Student(String nm)
>     {
>         name = nm;
>     }
>
>     public String getName()
>     {
>         return name;
>     }
> }
>
> I hope that helps
>
> Bryan
>
> Matthew Brandt wrote:
>
> Bruce, thank you for the input, I just updated to the most recent Java
> Version, I was running 1.4.x. Unfortunately that wasn't the fix. As for
> what Josh recommended, I'm afraid to say that I'm a bit confused. What is
> the last line of code that I need to add?
>
> import java.util.List;
> import java.util.ArrayList;
>
> and, a Student class. - What do you mean by this?
>
> matt
>
> ------------------- previous message-----------------------
> From Excercise 1.17 (lab-classes), http://bluej.org/download/download.html
>
>
> >>public class LabClass
> >>{
>     >>private String instructor;
>     >>private String room;
>     >>private String timeAndDay;
>     >> private List<Student> students;
>     >>private int capacity;
>
> ------------------------------
>
> _______________________________________________
> mailing list bluej-discuss at bluej.org
> To unsubscribe or change your preferences, go tohttp://lists.bluej.org/mailman/listinfo/bluej-discuss
>
>


-- 
Climb the mountains and get their good tidings. Nature's peace will flow
into you as sunshine flows into trees. The winds will blow their own
freshness into you, and the storms their energy, while cares will drop off
like autumn leaves.
~ J. Muir
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.bluej.org/pipermail/bluej-discuss/attachments/20060807/266acfc7/attachment.html


More information about the bluej-discuss mailing list