aspose file tools*
The moose likes Beginning Java and the fly likes Someone please tell me if this is right? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic
Author

Someone please tell me if this is right?

Rob Samberg
Greenhorn

Joined: Jan 28, 2006
Posts: 8
[code]

public class Product
{
// Sets the price of a product.
public void setPrice(double amount)
{
}

// Gets the price of a product.
public double getPrice()
{
}
[code]
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Can you define what you mean by "right"? As a programmer, there are many tools to help you know if a piece of code is "correct". The first one is the compiler. So does this code compile without any errors? If so, then you are on the first step.

The next thing is to understand what the code is supposed to DO. One way to check if a program DOES the right thing is to run it. At the moment, your code is not a complete program since there is no main() method. It is often helpful to write small programs that test only portions of your code, rather than writing the complete program and running it. Testing is its own field and it takes time to figure out how to test any particular code.

With that said, please come back with mroe questions. It will help a lot if you have SPECIFIC questions that we can answer.

Layne


Java API Documentation
The Java Tutorial
Rob Samberg
Greenhorn

Joined: Jan 28, 2006
Posts: 8
Hi Layne,
I might have specific questions if I knew what I was doing. Things are getting really messy now. Please help? I guess if I had one question for this mess, is what should be my main method? And, can you tell me what part of the code belongs in the Product.java editor and what belongs in the ProductTester.java editor.
[code]
public class Product
{

public Product()
{
Product productSale = new Product();
{

{
product.setPrice(29.95);
}
public class Product()
{
newProduct = Product - double amount;
}

{
product.getPrice();

System.out.println(newProduct);

}

}
[code]

Thanks. Sorry about the mess - it's really frustrating. I don't know what I'm doing. I'm starting to freak out.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Rob Samberg:
...I might have specific questions if I knew what I was doing...

That's a good place to start. Can you describe -- in English (not Java) -- exactly what you are trying to do? It's a lot easier to write code when the objectives are clear.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

This is really a continuation of this and this thread.

Rob, please try to keep this whole conversation in one thread -- otherwise you have to explain the problem all over again every time you post! So continue this discussion here; I'm closing this thread and the third one. Ask all your followups in that one thread.


[Jess in Action][AskingGoodQuestions]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Someone please tell me if this is right?
 
Similar Threads
Key Class for Products
hibernate self reference
Help wit h code
New class not working
Removing multiple if conditions