Could use a little help. please and ty!
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.
Code Java:
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
Code Java:
class 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,);
}
all the 8221's are actually " which is weird that its changing it to numbers
Re: Could use a little help. please and ty!
Welcome wyrven
Please use code tags when posting code on the forum. See the Announcements page for help.
Does the code compile?
Do you have a question about the code or assignment?
Re: Could use a little help. please and ty!
Quote:
Originally Posted by
jps
Welcome wyrven
Please use code tags when posting code on the forum. See the
Announcements page for help.
Does the code compile?
Do you have a question about the code or assignment?
Oh i see thanks for the announcements tip jps. and its compiling the first part but it is saying my 2nd part is having illegal characters. Also i just figured out i was using the wrong thing for my accessor.
I changed that but its just all around rough trying to catch up especially when my book is the first edition and the teacher wrote it with his knowledge not the knowledge that you would expect someone new to have.
Also just to make it a little clearer i would really just like some guidance on what ive done wrong to learn from it because i know i have i just can not pin point it myself.
And Thanks again!
Re: Could use a little help. please and ty!
Quote:
Originally Posted by
the wyrven
I changed that
Always post the new version of the code when changes are made
Quote:
Originally Posted by
the wyrven
on what ive done wrong
What makes you think you did something wrong? Is the output incorrect?
Re: Could use a little help. please and ty!
Thanks jps i figured it out finally! it just took a lot of reading and debugging but it eventually compiled properly.