Hey all. I was sick and missed 2 days of my Java class but i have been trying to catch up. This is my lab assignment that i didnt get till 2 days before it was due... i will post some of my code that i have worked on so far and if anyone could give me pointers because im having trouble understanding java since im mainly a C programmer. Thanks ahead of time to anyone who will help!
Suppose a company bought an item for certain amount of money and sells it. Do the following:
Part 1.
(a) Recognize that this situation describes an entity and give it a name.
(b) List possible attributes for this entity.
(c) List possible operations for this entity.
(d) List two objects for this entity. That is, give two exampls of such a transaction - in terms of their names, the cost of each item, and amount that each is sold for.
Part 2.
write a partial class definition to include:
(a) The name of the class, and
(b) The variable declarations for the class.
Part 3. Define an appropriate constructor for the class.
Part 4.
(a) Define accessor methods that returns the value prepresented by each variable.
(b) Include a mutator method that calculates the profit, (assuming profit was made).
(c) Provide mutator methods to change the name, the purchasing price, and the selling price of the product.
Part 5 Write a test class that will generate output.
So far my code is looking like this.
public class Riotsales { private int RP1points; private int RP2cost; private int RP2points; private int RPtotal; public Riotsales RP1 (int RP1sales, int RP2sales, int RPtotal) { RP1sales = 1000; RP2sales = 2000; RPtotal = RP1sales + RP2sales } public int getRP1() { return RP1sales; } public int getRP2() { return RP2sales; } public int getRPtotal() { return RPtotal; }
And here is my Test class which i know is really messed up
all the 8221's are actually " which is weird that its changing it to numbersclass TestRiotsales { public static void main (String[] args) System.out.println(“The total sales for the day are:” ); System.out.println(“-----------------------------------------------------“); System.out.println(); System.out.println(“1000 Riot points: ” + RP1sales, “ sales.”); System.out.println(“2000 Riot points: ” + RP2sales, “ sales.”) System.out.println(“Riot Corp.”); System.out.println(“--------------------------”); System.out.println(“Product: 1000 Riot Points”); System.out.println(“Purchase Price: $0.00”); System.out.println(“Sale Price: $” + RP2cost,); System.out.println(“--------------------------”); System.out.println(“Profit: $” + RP2cost,); System.out.println(); System.out.println(“Riot Corp.”); System.out.println(“--------------------------”); System.out.println(“Product: 2000 Riot Points”); System.out.println(“Purchase price: $0.00”); System.out.println(“Sale Price: $” + RP1cost,); System.out.println(“--------------------------”); System.out.println(“Profit: $” + RP2cost,); }