Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Someone please tell me if this is right?

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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]
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Politics is a circus designed to distract you from what is really going on. So is this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
    Bookmark Topic Watch Topic
  • New Topic