This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi - This is my first semester - I'm taking intro to Java and I'm supposed to write a program that sets a price for a toaster and then another toaster at 5% less and I'm supposed to test it. Can someone just push me in the right direction please?
Ok. Do you have an IDE? Have you installed Java? Do you need help with the code or all the way down to setting up the development environment?
Joined: Jan 28, 2006
Hi, I need help with the code. I have no I idea where to begin. All I have is:
public class Product
Here, I'll just write what the assignment says. Implement a class Product. A product has a name and a price, for example new Product("Toaster" , 29.95). Supply methods getName, getPrice, and setPrice. Write a program that makes twor products, prints the name and price, reduces their prices by $5.00, and then prints them again.
Anyway, that's what it says in the book. Then my teacher wants me to: Exercise P3.8 on page-99 of the text. Produce a neat self-explanatory output as desired by the problem description. When you decrease the price of a product, first use the getPrice() method to get its price, and then setPrice method to set its price to a new value.
Organize the two java classes (testProduct and Product) in two different files.
Can you help please? I have no idea where to even begin!
is a good start. Now you should write a constructor and some appropriate getX() and setX() methods (i.e. getPrice(), setPrice()). No one here will do the work for you, especially homework, but they will help you along the way if you get stuck. Are you familiar with writing constructors and methods?
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Joined: Jan 28, 2006
I'm working on it. I'll add some stuff and see what you guys think. Thanks.