Question: Based on the code below and the relation below. Write a separate function, in which submits the users order. The program acquires a confirmation of
Based on the code below and the relation below. Write a separate function, in which submits the users order. The program acquires a confirmation of submitting the order before it is submitted. The program returns back to the main menu with the function displayMenu() after the order is submitted and the cart is emptied. However, if the memeber does not confirm the submission of the order, the program also returns the main menu and the shopping cart stays intact.
MEMBER(last_name, first_name, email, password, user, street, city, state, zip, card_type, card_no, expiration, name_on_card)
CAR_SALE(listing_no, seller, isbn, condition, price)
ORDERS(order_no, buyer, order_date, total)
ITEMS(order_no, listing_no)
CAR(model, make, year, transmission, type, keywords)
import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import java.util.Scanner;
import javax.swing.event.CaretListener;
public class CarSale { class Car{ int car_no; String seller; String make; String model; int price; public int getCar_no() { return car_no; } public void setCar_no(int car_no) { this.car_no = car_no; } public String getSeller() { return seller; } public void setSeller(String seller) { this.seller = seller; } public String getMake() { return make; } public void setMake(String make) { this.make = make; } public String getModel() { return model; } public void setModel(String model) { this.model = model; } public int getPrice() { return price; } public void setPrice(int price) { this.price = price; } @Override public String toString(){ return "Seller: " + seller + " Price: " + price + " Make: "+ make + " Model: " + model; } } private static String url = "jdbc:postgresql://localhost/trainingdb"; private static String user = "postgres"; private static String password = "postgres"; private static String query = "SELECT * FROM CAR_SALE WHERE CAR_NO = ?"; public static Connection connect() { Connection conn = null; try { conn = DriverManager.getConnection(url, user, password); System.out.println("Connected to the PostgreSQL server successfully."); } catch (SQLException e) { System.out.println(e.getMessage()); } return conn; } public static void main(String args[]) { int count = 0; List
} }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
