Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
    Bookmark Topic Watch Topic
  • New Topic

Someone please tell me if this is right?

 
Rob Samberg
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Report post to moderator
[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
Posts: 3061
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
 
Rob Samberg
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Report post to moderator
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.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
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.
 
    Bookmark Topic Watch Topic
  • New Topic