RE: Java Question on Inheritance

2001-03-22 Thread Michael Wentzel

 Ultimately, I want to get the thumb of this Image and convert it to a URL.
I want  to be able to do this efficiently and use something like the
following syntax.
 
myImage.getThumb().toURL()
 
 
Is this possible?

Yes, but getThumb() must return a subclass of SuperOne.


---
Michael Wentzel
Software Developer
Software As We Think - http://www.aswethink.com
mailto:[EMAIL PROTECTED]

- Punisher of those who cannot spell dumb!



RE: Java Question on Inheritance

2001-03-22 Thread Grewal, Gary



No. 
The way you are doing means you are calling .toURL() method on what ever is 
returned by the method getThumb(). Unless getThumb returns a type of Object of 
type SuperOne or it's sub-class you cannot call this method and you should see a 
compile time error.

What 
you can do is 

URL 
url = toURL( myImage.getThumb() ); in your SuperOne or its 
sub-class.

=== Gary 
Grewal 

  -Original Message-From: Ryan 
  [mailto:[EMAIL PROTECTED]]Sent: Thursday, March 22, 2001 10:38 
  AMTo: [EMAIL PROTECTED]Subject: Java 
  Question on Inheritance
  
  I don't really know what to call what I'm having trouble with but here is 
  what I am trying to do.
  
  I have asuperclass called SuperOne, it has a method to convert a 
  string to a URL formatcalled toURL().
  
  I havean Image class that is a subclass of SuperOne. It holds 
  astringstoringthe local path of the image 
  onmyharddrive. This subclass contains a method to get the 
  corresponding thumbnail of the image on my harddrive. The method is called 
  getThumb().
  
  
  Ina thirdclass I want to instantiate an Image object 
  something like:
   Image myImage = new Image("/home/pic.gif");
  
  
  Ultimately, I want to get the thumb of this Image and convert it to a 
  URL. I want to be able to do this efficiently and use something like the 
  following syntax.
  
   myImage.getThumb().toURL()
  
  
  Is this possible?
  
  
  thanx
  -ryan


Re: Java Question on Inheritance

2001-03-22 Thread Ryan

Then this is my next problem.

I currently have getThumb() returning an Image object.

The part where I am stuck at is what to do in the toURL() method.

my mock getThumb() method currently looks something like
 public Image getThumb(){
  this.iValue = "/home/thumbs";
  return this;
 }


-ryan

- Original Message -
From: "Michael Wentzel" [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, March 22, 2001 8:32 AM
Subject: RE: Java Question on Inheritance


  Ultimately, I want to get the thumb of this Image and convert it to a
URL.
 I want  to be able to do this efficiently and use something like the
 following syntax.
 
 myImage.getThumb().toURL()
 
 
 Is this possible?

 Yes, but getThumb() must return a subclass of SuperOne.


 ---
 Michael Wentzel
 Software Developer
 Software As We Think - http://www.aswethink.com
 mailto:[EMAIL PROTECTED]

 - Punisher of those who cannot spell dumb!





RE: Java Question on Inheritance

2001-03-22 Thread Michael Wentzel

 Then this is my next problem.
 
 I currently have getThumb() returning an Image object.
 
 The part where I am stuck at is what to do in the toURL() method.
 
 my mock getThumb() method currently looks something like
  public Image getThumb(){
   this.iValue = "/home/thumbs";
   return this;
  }

Well, I would imagine your toURL() method would call a method that
has a default implementation in SuperOne and was overridden in any
subclasses that needed a different implementation.

i.e.
code
public java.net.URL toURL() {
java.net.URL url = null;
if (getFilename() != null) {
url = new java.net.URL(getFilename());
}
return url;
}
/code

It depends on what manner(servlet, applet, etc...) you are going to be using

these objects where you can get additional relative file name info for the
getFilename() method to include with the value in {SuperOne}.iValue.

In addition, you might consider changing your class name.  I caught
myself several times referring to java.awt.Image when you were
referring to Image class.  It's always best to create unique class
names whenever possible.  Maybe SuperImage or something to create
a mental correlation between this class and the class it extends.
Just a thought...

---
Michael Wentzel
Software Developer
Software As We Think - http://www.aswethink.com
mailto:[EMAIL PROTECTED]

- Punisher of those who cannot spell dumb!



Re: Java Question on Inheritance

2001-03-22 Thread William Brogden



Ryan wrote:
 
 Then this is my next problem.
 
 I currently have getThumb() returning an Image object.
 
 The part where I am stuck at is what to do in the toURL() method.
 
 my mock getThumb() method currently looks something like
  public Image getThumb(){
   this.iValue = "/home/thumbs";
   return this;
  }

  Exactly what are you going to do with an Image on the server side?
A request from a browser will be for an image file in something like
.gif of .jpg format.


-- 
WBB - [EMAIL PROTECTED]
Java Cert mock exams http://www.lanw.com/java/javacert/
Author of Java Developer's Guide to Servlets and JSP 
ISBN 0-7821-2809-2