首页 > > 详细

解析Java Assignment 编程、Assignment Java语言讲解留学生、辅导Java设计

import java.io.*;
import java.sql.*;
class Assignment {
public static Connection getConnection()
{
String user;
String passwrd;
Connection conn;
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
}
catch (ClassNotFoundException x)
{
System.out.println ("Driver could not be loaded");
}
user = readEntry("Enter database account:");
passwrd = readEntry("Enter a password:");
try
{
conn = DriverManager.getConnection("jdbc:oracle:thin:@daisy.warwick.ac.uk:1521:daisy",user,passwrd);
return conn;
}
catch(SQLException e)
{
System.out.println("Error retrieving connection");
return null;
}
}
public static void main(String args[]) throws SQLException, IOException
{
// You should only need to fetch the connection details once
Connection conn = getConnection();
boolean done = false;
do {
printMenu();
System.out.print("Enter your choice: ");
System.out.flush();
String ch = readLine();
System.out.println();
switch (ch.charAt(0)) {
case '1': option1(conn);
break;
case '2': option2(conn);
break;
case '3': option3(conn);
break;
case '4': option4(conn);
break;
case '5': option5(conn);
break;
case '6': option6(conn);
break;
case '7': option7(conn);
break;
case '8': option8(conn);
break;
case '0': done = true;
break;
default : System.out.println(" Not a valid option ");
}
} while(!done);
// Incomplete
// Code to present a looping menu, read in input data and call the appropriate option menu goes here
// You may use readEntry to retrieve input data
conn.close();
}
/**
* @param conn An open database connection
* @param productIDs An array of productIDs associated with an order
* @param quantities An array of quantities of a product. The index of a quantity correspeonds with an index in productIDs
* @param orderDate A string in the form. of 'DD-Mon-YY' that represents the date the order was made
* @param staffID The id of the staff member who sold the order
*/
public static void option1(Connection conn, int[] productIDs, int[] quantities, String orderDate, int staffID)
{
Statement ptids = conn.createStatement(); //get all product ids
String sqlString = null;
sqlString =
// Incomplete - Code for option 1 goes here
}
/**
* @param conn An open database connection
* @param productIDs An array of productIDs associated with an order
* @param quantities An array of quantities of a product. The index of a quantity correspeonds with an index in productIDs
* @param orderDate A string in the form. of 'DD-Mon-YY' that represents the date the order was made
* @param collectionDate A string in the form. of 'DD-Mon-YY' that represents the date the order will be collected
* @param fName The first name of the customer who will collect the order
* @param LName The last name of the customer who will collect the order
* @param staffID The id of the staff member who sold the order
*/
public static void option2(Connection conn, int[] productIDs, int[] quantities, String orderDate, String collectionDate, String fName, String LName, int staffID)
{
// Incomplete - Code for option 2 goes here
}
/**
* @param conn An open database connection
* @param productIDs An array of productIDs associated with an order
* @param quantities An array of quantities of a product. The index of a quantity correspeonds with an index in productIDs
* @param orderDate A string in the form. of 'DD-Mon-YY' that represents the date the order was made
* @param deliveryDate A string in the form. of 'DD-Mon-YY' that represents the date the order will be delivered
* @param fName The first name of the customer who will receive the order
* @param LName The last name of the customer who will receive the order
* @param house The house name or number of the delivery address
* @param street The street name of the delivery address
* @param city The city name of the delivery address
* @param staffID The id of the staff member who sold the order
*/
public static void option3(Connection conn, int[] productIDs, int[] quantities, String orderDate, String deliveryDate, String fName, String LName,
String house, String street, String city, int staffID)
{
// Incomplete - Code for option 3 goes here
}
/**
* @param conn An open database connection
*/
public static void option4(Connection conn)
{
// Incomplete - Code for option 4 goes here
}
/**
* @param conn An open database connection
* @param date The target date to test collection deliveries against
*/
public static void option5(Connection conn, String date)
{
// Incomplete - Code for option 5 goes here
}
/**
* @param conn An open database connection
*/
public static void option6(Connection conn)
{
// Incomplete - Code for option 6 goes here
}
/**
* @param conn An open database connection
*/
public static void option7(Connection conn)
{
// Incomplete - Code for option 7 goes here
}
/**
* @param conn An open database connection
* @param year The target year we match employee and product sales against
*/
public static void option8(Connection conn, int year)
{
// Incomplete - Code for option 8 goes here
}
private static String readEntry(String prompt)
{
try
{
StringBuffer buffer = new StringBuffer();
System.out.print(prompt);
System.out.flush();
int c = System.in.read();
while(c != '\n' c != -1) {
buffer.append((char)c);
c = System.in.read();
}
return buffer.toString().trim();
}
catch (IOException e)
{
return "";
}
}
private static String readLine() {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr, 1);
String line = "";
try {
line = br.readLine();
} catch (IOException e) {
System.out.println("Error in SimpleIO.readLine: " +
"IOException was thrown");
System.exit(1);
}
return line;
}
private static void printMenu() {
System.out.println("\n Menu ");
System.out.println("(1) In-Store Purchases. ");
System.out.println("(2) Collection. ");
System.out.println("(3) Delivery. ");
System.out.println("(4) Biggest Sellers. ");
System.out.println("(5) Reserved Stock. ");
System.out.println("(6) Staff Life-Time Success. ");
System.out.println("(7) Staff Contribution. ");
System.out.println("(8) Employees of the Year. ");
System.out.println("(0) Quit. \n");
}
 

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!