ArrayList is empty.. Need a help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ikkyizzy
    New Member
    • Nov 2016
    • 16

    ArrayList is empty.. Need a help

    Hi Guys who are online,

    Please help me to solve this problem.
    Code:
    ublic static void ViewFoodTruckInfo() {
            // 1 user wants to view information about food trucks
            // 2 User login with username and password
    
            System.out.println("Enter username : ");
    
            String username = sc.next();
    
            System.out.print("Enter password : ");
            String password = sc.next();
            // Username and password is searched
    
            User foundCust = objCustomer.searchUserByName(username);
            User foundPass = objCustomer.searchUserPassword(password);
    
            // If username and password is correct
            if (foundCust != null && foundPass != null) {  // If the user is a Customer  fullname and email is shown
    
                System.out.println("Name :  " + foundCust.getFullName());
                System.out.println(" Email :" + foundCust.getEmail());
                // Customer selects to view food trucks based on location or foodtype
    
                System.out.println("Do you wants to (V)iew foodTrucks  Or (R)eview foodTrucks : ?  ");
                String input = sc.next();
                if (input.equalsIgnoreCase("V")) {
                    // Customer enter foodtype of location
                    System.out.println("Enter truck Food Type or Location  : ");
                    String stringans = sc.next();    // type or location is searched
                    FoodTruck found = objFoodTruck.FoodTruckByTypeOrLoc(stringans);
    
                    // If location or foodtype matches a FoodTruck
                    if (found != null) {
                        System.out.println("FoodTruck Name  : " + found.getTruckName());  //  found food Truck Average rating and list of review is shown
                        System.out.println("Food Truck Average Rating  :  " + foundCust.getAverageRatings());
                        System.out.println("Food Truck's list of review   : " + found.getListReviewReceived().toString());
    
                    } else {
                        System.out.println("There is no Truck by that foodtype or Location..");
                    }
    
                } else if (input.equalsIgnoreCase("R")) {
                    // method to review
                    ReviewFoodTruck();
    
                } else {
                    System.out.println("You can (V)iew or (R)eview FoodTruck Only!!");
                }
    
            }
    
        }

    ------------------------------------------------
    System.out.prin tln("Food Truck's list of review : " + found.getListRe viewReceived(). toString());

    getListReviewRe ceived is appearing empty

    I have uploaded the whole program. So you guys will be
    able to understand my problem.

    https://www.dropbox.com/s/01hzol5d728xwmz/BIT203%20Assign ment%201.pdf?dl =0

    https://www.dropbox.com/s/kh6ecpyp9ghy53y/BIT203%20Assign ment%202.pdf?dl =0

    https://www.dropbox.com/s/25xo3emf2gidpdf/FTTConsole.zip? dl=0
  • chaarmann
    Recognized Expert Contributor
    • Nov 2007
    • 785

    #2
    Your problem: "found.getListR eviewReceived() " in line 35 returns an empty object, so that its toString() method prints nothing.
    Is that correct?

    To be able to analyze the problem, please list the method "getListReviewR eceived()" of class "FoodTruck" here.

    remarks:
    Searching through all your dropbox files is too time consuming for a free helping hand and you have to list it here in the forum anyway, so that others that have the same problem as you can easily see the problem and its solution. Or do you think everybody wants to open dopbox-files (maybe a few years later!) only to see the problem? What if the dropbox vanishes? A broken link is worse. So please do us a favour and list the relevant file here directly.(And please not all the irrelevant files!). If the file is long, then not the whole file, but only the code snippet that has the problem. In this way we can help you best.

    Comment

    Working...