-
I need help writing a program
Im having problems writing code for this program I have due Monday. Any and all help would be greatly appreciated!! Here's my problem.
Order class, contains an order number, customer name, and address(assume its just a street address), a list of item numbers ordered(up to four) this part is an array, the total price of all items ordered and shipping and handling fee for the order. Include a constructor to set the field values and get methods to retrieve the field values.
This is what I have come up with so far im just not sure if its all correct.
Code:
public class Order
{
private int orderNum;
private String name;
private String address;
private int itemNums;
private double totPrice;
private double sah;
Order()
{
int orderNum = 0;
String name = "";
String address = "";
int[] itemNums = new int[4];
double totPrice = 0.0;
double sah = 0.0;
}
public int getOrderNum()
{
return orderNum;
}
public String getName()
{
return name;
}
public String getAddress()
{
return address;
}
public int getItemNums()
{
return itemNums;
}
public double getTotPrice()
{
return totPrice;
}
public double getSah()
{
return sah;
}
}
-
well what part of you having trouble with? Nobody is just going to do the assignment for you, so you'll have to ask something specific.
So far, that code won't compile and here's why.
private int itemNums;
int[] itemNums = new int[4];
You've defined the same variable twice, once as an integer and a second time as an array of integers.
Will the number of orders always be 4? Seems like an unsafe assumption.
-
yes there will always be 4 orders taken in.
-
I just want to know if this code is right it seems to compile but I feel as if theres something missing from it. There will be 4 orders taken in by it thats why theres an array. Any help would be greatly appreciated.
Thanks
If you need to see the problem for this class I will post it up if that would help. I dont want anyone to write the class for me just to help me put the finishing touches on it.
Similar Threads
-
By divagoddess in forum C++
Replies: 5
Last Post: 08-14-2009, 03:12 PM
-
Replies: 2
Last Post: 03-07-2002, 07:49 AM
-
By Gordon Reichhardt in forum VB Classic
Replies: 2
Last Post: 01-08-2002, 10:06 AM
-
By W.Pierce in forum VB Classic
Replies: 1
Last Post: 12-11-2001, 08:28 AM
-
Replies: 1
Last Post: 06-22-2001, 06:29 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|