I need help writing a program


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: I need help writing a program

  1. #1
    Join Date
    Feb 2006
    Posts
    4

    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;
    	}
    	
    }

  2. #2
    Join Date
    Mar 2004
    Posts
    635
    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.

  3. #3
    Join Date
    Feb 2006
    Posts
    4
    yes there will always be 4 orders taken in.

  4. #4
    Join Date
    Feb 2006
    Posts
    4
    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

  1. soft drink Vending machine program
    By divagoddess in forum C++
    Replies: 5
    Last Post: 08-14-2009, 04:12 PM
  2. Replies: 2
    Last Post: 03-07-2002, 08:49 AM
  3. Please help with running executable vb program.
    By Gordon Reichhardt in forum VB Classic
    Replies: 2
    Last Post: 01-08-2002, 11:06 AM
  4. How can I build copy protection into my program
    By W.Pierce in forum VB Classic
    Replies: 1
    Last Post: 12-11-2001, 09:28 AM
  5. writing a search program...
    By snz in forum ASP.NET
    Replies: 1
    Last Post: 06-22-2001, 07: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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center