Question
Part 1: Connecting to and Retrieving data from MongoDB in a Java Application. Complete the code for the findRestaurants() method so that it finds restaurants
Part 1: Connecting to and Retrieving data from MongoDB in a Java Application.
Complete the code for the findRestaurants() method so that it finds restaurants by cuisine and ZIP code. You should use a regular expression for the cuisine.
Complete the code for the getRestaurantInfo() so that it pulls up the information on the restaurant selected by the user.
Complete the code for the getRestaurantGrades() method so that the program displays reviewer grades for the restaurant.
package u05a1restaurantmongo;
import com.mongodb.BasicDBObject; import com.mongodb.MongoClient; import com.mongodb.MongoClientURI; import com.mongodb.client.MongoCollection; import com.mongodb.client.MongoCursor; import com.mongodb.client.MongoDatabase; import static com.mongodb.client.model.Projections.fields; import static com.mongodb.client.model.Projections.include; import java.util.ArrayList; import java.util.Scanner; import java.util.logging.Level; import java.util.logging.Logger; import static javax.swing.UIManager.get; import org.bson.Document;
/** * * @author IT4736 */ public class U05a1RestaurantMongo { // Private class field to provide access to appropriate collection private static MongoCollection
} /*--------------------------------------------------------------------------------------------------------- Restaurant ID passed as string to getRestaurantInfo() method. This method should return a Restaurant object. -----------------------------------------------------------------------------------------------------------*/ static public Restaurant getRestaurantInfo(String restaurantID) { /*------------------------------------------------------------------------------------------------------------- >>> COMPLETE THE CODE FOR THIS METHOD <<< Complete this method so that it finds the restaurant by the restaurant_id. The method should return a Restaurant object with the information. ---------------------------------------------------------------------------------------------------------------*/ } /*--------------------------------------------------------------------------------------------------------- Restaurant object passed to getRestaurantGrades() method. This method list the grades/ratings, so return type is void. -----------------------------------------------------------------------------------------------------------*/ static public void getRestaurantGrades(Restaurant restaurant) { /*------------------------------------------------------------------------------------------------------------- >>> COMPLETE THE CODE FOR THIS METHOD <<< Complete this method so that it displays the grades for the restaurant passed in as a Restaurant object. ---------------------------------------------------------------------------------------------------------------*/ } static public String getRestaurantChoice(MongoCursor
might need to
In the NetBeans project tree on the left side of the window, right click on the Libraries folder and add the 3 .jar files needed for MongoDB (mongodb-driver-3.6.1.jar, mongodb-driver-core-3.6.1.jar, and bson-3.6.1.jar).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started