Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: problem with code

  1. #1
    Junior Member
    Join Date
    Dec 2009
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default problem with code

    import java.util.*;
     
     
    /**
     * Write a description of class StockControl here.
     * 
     * @author (your name) 
     * @version (a version number or a date)
     */
    public class StockControl
    {
    private ArrayList<Product> stockList = new ArrayList<Product>();
    private ArrayList<Item> sales = new ArrayList<Item>();
     
    public void addProductToStockList(String name, int stockLevel,
     int reorderLevel, int orderLevel){
         stockList.add(new Product(String name,int stockLevel,int reorderLevel,int orderLevel));
    }
        /**
         * Adds the item
         */
        public void addSale(String name, int quantity)
        {
            sales.add(new Item(name, quantity));
        }
     
        /**
         * Find a product.
         */
        private Product findProduct(String name)
        {
            for (Product product: stockList)
            if (product.getName().equals(name))
            return product;
            return null;
        }
     
        /**
         * DO the order
         */
    public void orderProducts(){
    for (Items item: sales){
    Product product = findProduct(item.getName());
    if (product == null){
    System.out.println("Item" + item.getName() + "not recognised. Inform IT support.");
    return;
    }
    product.setStockLevel(product.getStockLevel() - item.getQuantity());
    }
    String orders = "";
    for (Product product: stockList){
    if (product.getStockLevel() <= product.getReorderLevel())
    orders = orders + product.getName() + " " + (product.getOrderLevel() - product.getStockLevel()) + "\n";
    }
    System.out.println(orders);
    }
    }

    The problem is appearing here:
     stockList.add(new Product(String name,int stockLevel,int reorderLevel,int orderLevel));

    compilator writes next: ) expected


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: problem with code

    Can you attach the rest of your code so I can attempt to compile this? Thanks.
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

Similar Threads

  1. Problem with code
    By lichad3 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 22nd, 2011, 06:40 PM
  2. Problem with the code
    By noFear in forum What's Wrong With My Code?
    Replies: 10
    Last Post: August 9th, 2010, 10:28 AM
  3. problem in my code
    By wannabe in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 24th, 2010, 07:53 AM
  4. Problem with Recursive code
    By Shadow703793 in forum Algorithms & Recursion
    Replies: 4
    Last Post: February 22nd, 2010, 09:36 PM
  5. code needed for the following problem
    By romilc in forum Java Theory & Questions
    Replies: 1
    Last Post: October 11th, 2009, 10:05 AM