Richard Chambers

Ranch Hand
+ Follow
since Apr 03, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Richard Chambers

I probably know less than you do, but I'll post anyway with the advise of listening to the wiser ones.

I'd make the txt file a CSV file, and use an array to access it.

Just my thoughts.
13 years ago
OK, I'm back. I took a Java course this spring at the local college, and learned enough to know I don't know what I'm doing. I'm now starting Head First Java with a study buddy. We're in Chapter Two - Objects, It's one of those complete the code from a list of "snippet" things. We chose different codes, yet have the same output. Neither of us can explain why we chose the differing snippets other than we worked it through our heads and this one worked. Can someone explain which of the coding is preferred and why? or does it matter and both are right.

Thanks

My Coding



His Coding



BTW -- My coding agrees with the book, so I assume his is wrong, but I can't show him why.

Thanks again
[ September 17, 2008: Message edited by: Richard Chambers ]
13 years ago
Thanks Stevi

That was it

and I made my midnight deadline to turn it in too.

Now to take my final exam,

then I can get Head First Java and "really" learn this stuff.

Thanks everyone

I'm sure I'll have a few thousand questions as I study on my own this summer.
13 years ago
Thanks Stevi

a basic question I must of missed:

the shapes[] in the loadShapesArray method is
and instance variable.

loadShapesArray is private static

is the instance created differently than the local?

it's originally created as a private static constructor
of the ShapeTest class

so it's available throughout that class?

by declaring it again in the private static loadShapesArray
method of ShapeTest class doesn't that let me modify it
within the loadShapesArray?

But then again, I'm calling loadShapesArray from the main method
of ShapeTest, so I must be passing values back to the main somehow?

I'm very confused right now.

Any suggestions?

Thanks
13 years ago
Dumb question
I have another thread going for my nullPointerException error
and am still troubleshooting it but I'm wondering if this might
be the problem, or just something I'm not getting at the moment.

Our class has us coding from pseudo code. Not a good way to learn Java.

the pseudo I have a question about is this:


This is my coding for the class it appears in:



Sorry to use so much code for the question.
What I'm wondering is ----
where does currentShape come from.
I have 11 class files in this project, and I'm not defining it anywhere that I can see. This is early in the main method, so it should be defined and initialized or assigned or whatever before I'm using it, but if it's there I'm blind. Did the teacher throw a curve and I'm using the wrong name maybe? or is this some internal JAVA thing that's refering to the array created in myFields. It has a shape field in it.

The more I learn the more confused I get

HELP PLEASE

I need to get this running and turned in tonight, last project of the semester.

Thanks
13 years ago
My textbook is based on 1.5, and I use 1.6

We covered Switch, and I've used it in course projects.

Not hard to learn, 10 or 15 minutes and you'll have it.
13 years ago
Shirt is the type of "s"

If you program is dealing with a closet,
you'd have Shirts, Pants, Coats, etc...

"s" in this case would be how many of the type.

Hope this helps,

btw, I'm struggling to finish my first semester JAVA class too,
so others will have more clarification or correction for me I'm sure.
13 years ago
I'm still proofing and pulling hair,
so I'm going to post more info and pray for help.

here's the for loop pseudo code:




and here's my coding:




I HATE posting code like this and fishing,
but believe me, I've checked everything I know about
and have spent hours on this before asking for help.

I know it will be something obvious that I'm just missing,
but that's the benefit of extra eyes.

Thanks for all your help.

Last assignment for this dang class, due tonight
and I have an A so far, don't want to blow it on
a silly "for" loop.
13 years ago
AAAACK

now I have a NullPointerException error

thats a new one for me

The line the runtime points to is my for loop in the main method

again, the pseudo code is:



my coding is:



I think this is right. I'm not familiar with
NullPointerException, not really sure what
it means or where to look to fix it.

Thanks

btw, dang brackets, got me out of the if loop though
13 years ago
am I "interpreting" this right?

the pseudo code




my coding:



or is it this:



This is where the debugger is hanging, it just keeps looping at this command.

I also have proven my eyes are bad in previous problems.
I don't always see the obvious.
Have I missed a bracket? I don't think so,
and have checked, rechecked, marked, etc ...
but I still make mistakes
MANY mistakes.

Thanks
[ May 09, 2008: Message edited by: Richard Chambers ]
13 years ago
An update

it's hanging in the first if loop with the circle

why?

I've also gone back to my original thinking in the coding

I'm now using

Circle shape = new Circle format

that could still be wrong but seems to make more
sense to my muddled mind.

Thanks again for the help
13 years ago
Another lesson learned.

Just because all 11 class files compile doesn't mean it works.

I hate to ask this, but I'm in the final hours of this class
and time is running out. Someone please have pity and get me
going in the right direction.

I've "isolated" my problem to this method by debugging,
but have no idea why this method is hanging up.

Here's the pseudo code I wrote off of:


and here's my coding for it:




again I appologize, I hate to just post code.

my "guesses" would be in the instance variable shapes declaration,

or
my assignments of the shapes[index]

I've also tried to write it as Shape shapes = new Shape format

and it compiles, but still hangs the program up.

Thanks
[ May 09, 2008: Message edited by: Richard Chambers ]
13 years ago
Thanks for all the help

Who'd of thought - a typo.

My frustration over the textbook would probably be
better directed at the instructor.

I'm taking this course at a local community college.

I chose to take it there BECAUSE I didn't want self instruction.

This whole semester we've had one lecture -
and it was "THIS CLASS CONSISTS ENTIRELY OF LABS-
DON'T BOTHER ME"

One student asked a question on the first project,
and he chewed him out in front of everyone.

No one has dared ask a question since.

The book has ten chapters, and we had ten projects and ten tests

Our projects have NOTHING to do with the material in
the current chapter we are studying. Very frustrating.

We've had ten test. The tests also have very little to
do with the material in the chapter it is for.

Each test has also had several questions where he gives code
and we're supposed to tell what it outputs.

What can I say, I cheated. I cut and paste the code into my text editor.
compile it, run it. enter the output on the test.

50% of the time he marks it wrong and claims a different output.

The book is Deitel's Small Java.

perhaps it would be a good book with a good instructor.
It is not good for self study. I read a section many times,
just to figure out what it is saying. Way too much needless prose.
One of my biggest frustrations, is it will use terminology in Chapter 3, that it doesn't introduce until Chapter 8. I spent a large amount of
time skipping through the book trying to figure out what it was talking about. I also bought JAVA for Dummies as a "Desk reference". The text will spend lot's of pages on a concept, and thouroughly muddy it.
At least with Dummies, I can clarify it to a couple of paragraphs.


I can see that if an instructor lectured, covering the high points of
each chapter, then used assignments and projects from that chapter,
it could have potential.

Reading other threads, I find that the JAVA I am learning, is not
the practical stuff I will be able to use. For our projects,
the instructor fleshes out our programs with psuedo code, and we
complete the programming. I've become good at translating, pseudo code
to JAVA, but that is NOT JAVA programming, and I don't feel comfortable
writing anything much more complicated than "Hello World", 5 months and $1000 later. We've not even mentioned graphics.

I also see where Deitel's website lists the book as having 900+ pages,
our text is much smaller, and I suspect a Readers Digest version.

I've also located our "projects", and find they are in Dietel's C++ text.

I feel like I'm reading a text translated from a foriegn language,
with projects adapted from a totaly different text for a different
programming language.

I DID learn enough to know I want to actually learn JAVA.

I turn in this project, and take my final, then I am done with this stage.
Next week, I'll look through the book reviews here again, but I think
I'll get HeadFirst, and self study my way through it. Someone's also suggested Thinking In Java.

Thanks again for everyone's help. And as I actually start LEARNING JAVA
this summer, I'm sure I'll be back often with questions.
13 years ago
I have a few general questions about the assignment I'm completing

I'm trying real hard to understand this stuff, but have a poor textbook

and a worse instructor.

The assignment deals with Shape hierarchy

I've created several class files for this package
Shape is a super class
TwoDimensionalShape and ThreeDimensionalShape classes extend Shape
Square and Circle extend TwoDimensionalShape
Cube and Sphere extend ThreeDimensionalShape

Now for the questions.

I know what the concrete methods of the abstract methods of the superclass,
but do I have some special keyword or other way of identifying them?
or do I just declare them like a normal method.

What is protected used for. My text only says that it is a legal keyword for a class or method, but doesn't explain anything.

and very specifically, the only error in my 11 file program:

in my class cube I have this method:



I have essentially the same code in class Sphere, and it compiles OK.

why?

the toString method is in Shape - two levels up from Sphere and Cube.

again, Sphere and Cube both extend ThreeDimensionalShape
ThreeDimensionalShape is abstract
ThreeDimensionalShape extends Shape
Shape is also abstract
all are public, none are static

Thanks

(This is my last assignment in this class.
I'm going to buy HeadFirst Java and learn it for real now)
13 years ago
OK, I answered my own question

never fails, I struggle for hours, and
minutes after posting the solution hits me

it's only 8 digits, the comma and . don't count

8.2 instead of 10.2 makes it come out right

Thanks everyone
13 years ago