Pat Barrett

Ranch Hand
+ Follow
since Jan 03, 2001
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
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 Pat Barrett

You're actually creating a new String object!
pb
18 years ago
Hello,
I initially thought that Johannes wanted us to edit the chart directly, but that is not allowed. After re-reading the original post, he said to "post to the topic" and then, "after you have posted, edit that post with any updates" (or something similar). At least, that's how I understood it.
Pat B.
18 years ago
Hello Johannes,
I'm at:
Assignment: Servlets - 4a
Attempts: 0
Thanks,
Pat B.
p.s. Just to let you know that I haven't given up! I've been tied up with a work assignment but I hope to be submit again by the end of the week.
[This message has been edited by Pat Barrett (edited April 30, 2001).]
18 years ago
Hello Johannes,

I've been given permission to proceed to the Lookup assignment - 3.4. Version 1 will be going in today.
Pat B.
18 years ago
Hello,
A "zillion" is defined as an extremely large indefinite number. At one point I thought I'd be submitting a zillion different versions of the Say assignment. If you're stuck, I'd suggest walking away from it for a day or so. Bits of insight or an outright solution have a way of popping into your head when your mind is on something else.
Pat B.
18 years ago
Hello,
Since you are actually comparing Strings you need to use the equals() method. For example; numbers.substring(1,2).equals("0").

Also, assuming that "numbers" is your input argument, that particular string is going to only check the 2nd position of the string. For example, if numbers is equal to '10' your statement would return true. If numbers was equal to 101 it would return true as well. Is this what you intend the statement to be checking for?
Pat B.
18 years ago
Thanks Marilyn,
I'll stop pulling what's left of my hair out.
Pat B.
18 years ago
Hello,
I'm working ahead a bit and I've run into a snag trying to get setup for the servlet assignments. I've found my exact problem described here:
http://www.javaranch.com/ubb/Forum7/HTML/001387.html
When I made the suggested fixes, the testservlet code wouldn't compile - I had to re-instate my previous classpath so I'm basically back to where I started. If anyone has had this same issue and they were able to get past it (J.C. Cook??) please let me know.
Thanks,
Pat B.
18 years ago
Hello,
I have a version of Khalid's book where question 1.4 is as follows:
Given that Thing is a class, how many objects and reference variables are created by the following code?

The correct answers given are B ( Two objects are created ) and F ( Three reference variables are created ) which are correct.
Is it possible that you are looking at an older version of the book? Mine was published in 2000 and says "covers Java 2 platform" on the lower right hand corner of the cover.
Pat B.
18 years ago
Thanks for the reply Andy,
Your answer wasn't the right one, but it got me to realize what the problem actually was. Before I got to the part in the TIJ book about saving all your package files in their own directory I had originally saved and compiled myClass in the javaprog directory. Later, I added the mypackage directory and rather than moving the file I copied it, leaving a different version of myClass in the javaprog directory. Since the CLASSPATH just provides a starting point for the compiler to look for the necessary packages it was hitting my original myClass, which was the cause of the error.
I hate to admit such a mindless error, but hopefully this will help someone else down the road.
Thanks again,
Pat B.
18 years ago
Hello,
I've been cruising along nicely until I tried creating my first package. I'm working out of chapter 5 in Thinking in Java and I'm having the following problem.
First, the preliminaries... I'm working on Windows 95 using JDK 1.3. My CLASSPATH is:
SET CLASSPATH=.;C:\jdk1.3\bin;C:\javaprog;C:\javaprog\javaranchcommon.zip;
In my javaprog directory I have the following file:

In the c:\javaprog\mypackage folder I have the following file

MyClass.java compiles fine, but I get the following error when I compile PackTest.java:
[Windows 95] C:\javaprog>javac PackTest.java
PackTest.java:6: cannot access MyClass
bad class file: .\MyClass.class
class file contains wrong class: mypackage.MyClass
Please remove or make sure it appears in the correct subdirectory of the classpa
th.
new MyClass() ;
^
1 error
I have things setup the same way on a Win 2K system and it works fine, but I'm at a loss as to why it doesn't work on my home Win 95 system.
I have a suspicion that the solution to this is staring me in the face, but I'm not seeing it. I would appreciate any insight anyone here could offer.
Thanks in advance,
Pat B.
18 years ago
Hello,
Technically, you could have any class extend any other class. However, good OOP design demands that there be an "is-a" relationship between a class and any other classes that may inherit from it. This is one reason why OOP is so versitile as it allows for easy expndability and extensibility.
The classic example given is that of the Shape class. Conceptually, it's not too hard to envision that a Square or a Circle are both Shapes (a square "is-a" shape, a circle "is-a" shape), yet they look quite a bit different. I believe that the lack of the same "is-a" relationship between stars and planets is the reason for the unexpected answer on the Khalid question. There's no technical reason why you can't have a planet inherit from a star, there's just not a good conceptual one.
Pat B.
Don,
You should probably read the "cattle drive" section of this web-site for instructions on how to submit the assignments. This forum should be used to discuss the assignments, but the code should not be posted here.
Pat B.
18 years ago
Hello,
A star is defined as a large ball of hot gas, thousands to millions of kilometers in diameter. A planet is defined as a non-luminous body that revolves around a central star. Stars differ fundamentally from planets in that they are self-luminous, where planets shine by reflected light from their near-by sun.
Although planets and stars are related, there does not exist the "is-a" relationship that good inheritance demands. You could probably use inheritance to define a relationship between black-hole's and stars, or white-dwarves and stars, as these objects are closely related.
hth...
Pat B.
Pat B.
Hello,
The setLength method of stringbuffer when used with an int constructor will set the length of the buffer to whatever the integer argument is. Using zero will essentially set the length to zero, effectively clearing the buffer. For more info on String buffer see...
http://java.sun.com/products//jdk/1.2/docs/api/java/lang/StringBuffer.html
Pat B.
18 years ago