aspose file tools*
The moose likes Beginning Java and the fly likes Javadoc Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Javadoc" Watch "Javadoc" New topic
Author

Javadoc

Heather Dennison
Greenhorn

Joined: Jan 27, 2011
Posts: 16
I am a beginner at Java. I have a project to turn in tonight. I have read what javadoc is... but I am having trouble labeling my program:


Can anyone help me with this? It counts 20% of the grade. And I need to know how for next time.
Thanks!!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41879
    
  63
Does this help: http://download.oracle.com/javase/1.5.0/docs/tooldocs/windows/javadoc.html


Ping & DNS - my free Android networking tools app
Heather Dennison
Greenhorn

Joined: Jan 27, 2011
Posts: 16
Thanks Ulf.. I have read that. And I see what it is.. but I need to actually see the javadoc being used on a project to give me an idea of what and where things go. Kind of like MLA - I had to see examples.
Heather Dennison
Greenhorn

Joined: Jan 27, 2011
Posts: 16
I'm also having problems setting my decimals to 2. here is my automobile test...
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Please UseCodeTags when posting code. It will highlight your code and make it much easier to read. Since you're relatively new I'll add them for you.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

I'm not sure what your question is. You said that you're having "problems" but you've never said what those problems are. Can you tell us what you expect to happen and what actually happened? In short: TellTheDetails.

I have a small remark about your code: don't use public non-final methods in your constructor. The reasoning behind this is that extending classes will not be able to use instance variables in their implementations of those functions. The reason behind this is that the super constructor hasn't completed yet. This might be hard to understand (it isn't "Beginning Java" material) but it has to do with the sequence in which an object is build. In your case just use the instance variables directly.
Heather Dennison
Greenhorn

Joined: Jan 27, 2011
Posts: 16
Thanks, Wouter. And no.. i really do not understand.

(1)I need to have the correct javadoc format on this program. And I do not.. @para.. etc.
(2)When I run this program the output of the price amount does not have 2 decimals. I need it to be set to dollar and I am not sure how to.
(3) How do I set instant variables directly?
Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
(2)When I run this program the output of the price amount does not have 2 decimals. I need it to be set to dollar and I am not sure how to.

Take a look at the String.format() method.

(3) How do I set instant variables directly?

You are doing it in your code here:
Ralph Cook
Ranch Hand

Joined: May 29, 2005
Posts: 479
Heather Dennison wrote:Thanks, Wouter. And no.. i really do not understand.

(1)I need to have the correct javadoc format on this program. And I do not.. @para.. etc.


Because you're in a hurry, I am going to *try* a shortcut for you.

Put javadoc comments, as you have, between /** */.

Put one for the class after the import statements but before the class declaration (public class ...)

Put one for each method just before the method declaration.

Put the tag "@param" in for each parameter used by the method. go to this link

http://download.oracle.com/javase/1.5.0/docs/tooldocs/windows/javadoc.html#comments

and read it about entering comments; search for "param" and follow a link specifically about writing param comments.

Most java code I've seen doesn't have anything approaching complete javadoc; if a class I'm using has class and method documentation I consider myself fortunate. If it actually matches the code I'm ecstatic. But that may not cut any ice with your class. However, if you're on real short time and want to do it "the industry way", if you got class and method descriptions in place it would look pretty good to me.



(2)When I run this program the output of the price amount does not have 2 decimals. I need it to be set to dollar and I am not sure how to.

Unfortunately, this is going to take a little digging. Your answer lies in the method String.format, in a class called Formatter. Since you're in a hurry, I recommend you google something like "java output 2 decimal places" and hope for the best.
(3) How do I set instant variables directly?


Within your constructor, there is no need to call a method to set the private variable values, you can just assign values to them, like


Hope that all helps
rc
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19696
    
  20

Ralph Cook wrote:

There, I fixed it for you. The @param parameter names should of course match the actual parameter names.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Ralph Cook
Ranch Hand

Joined: May 29, 2005
Posts: 479
Well, I suppose it's neater that way, but I don't see why the name the programmer uses internally should matter to the name given to the calling programmer. They don't affect him. I mean, as a convention it's fine, but it wasn't broken.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38881
    
  23
I agree with Rob; the parameter names in the documentation comment (the official name for what we always call "javadoc") were different from the names of the parameters. I would personally use this conventionNotice here we are preserving the excellent names of the fields, which I chose after several seconds of hard work blood sweat and tears, and exposing those names to users of the constructor.The overloaded constructor with one argument can only throw a NullPointerException, never an IllegalArgumentException.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19696
    
  20

Ralph Cook wrote:Well, I suppose it's neater that way, but I don't see why the name the programmer uses internally should matter to the name given to the calling programmer. They don't affect him. I mean, as a convention it's fine, but it wasn't broken.

The name used doesn't matter much, but the @param names must match the actual parameter name. It's not a choice, that's how Javadoc works. The method declaration as you wrote it will be part of the Javadoc. If the @param tags then have different names users will not be able to match the two together.

Taking your example, the Javadoc would say that "name" is "what we call this auto". So I check the method parameter list, and I can't find any parameter called "name". Now what?

But I would not use the "given" prefix either. Just use this. like Campbell did.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Javadoc