private static void updateProduct()
{
ProductMaintApp.updateProduct();
}
Do I need to add get and set methods as well?
Thanks
This post has been edited by rollsroyce: 24 June 2009 - 08:05 AM




Posted 24 June 2009 - 08:03 AM
private static void updateProduct()
{
ProductMaintApp.updateProduct();
}
This post has been edited by rollsroyce: 24 June 2009 - 08:05 AM
Posted 24 June 2009 - 08:06 AM
Posted 24 June 2009 - 08:09 AM
Posted 24 June 2009 - 08:25 AM
kmangold, on 24 Jun, 2009 - 07:13 AM, said:
public void updateProduct(String pro){
this.pro=pro;
}
Posted 24 June 2009 - 08:29 AM
kmangold, on 24 Jun, 2009 - 07:13 AM, said:
Posted 24 June 2009 - 08:57 AM
Fuzzyness, on 24 Jun, 2009 - 09:29 AM, said:
Quote
Posted 24 June 2009 - 09:39 AM
nick2price, on 24 Jun, 2009 - 07:25 AM, said:
kmangold, on 24 Jun, 2009 - 07:13 AM, said:
public void updateProduct(String pro){
this.pro=pro;
}
import java.util.Scanner;
public class ProductMaintApp
{
// declare two class variables
private static ProductDAO productDAO = null;
private static Scanner sc = null;
public static void main(String args[])
{
System.out.println("Welcome to the Product Maintenance application\n");
// set the class variables
productDAO = DAOFactory.getProductDAO();
sc = new Scanner(System.in);
// display the command menu
displayMenu();
// perform 1 or more actions
String action = "";
while (!action.equalsIgnoreCase("exit"))
{
// get the input from the user
action = Validator.getString(sc,
"Enter a command: ");
System.out.println();
if (action.equalsIgnoreCase("list"))
displayAllProducts();
else if (action.equalsIgnoreCase("add"))
addProduct();
else if (action.equalsIgnoreCase("update"))
updateProduct();
else if (action.equalsIgnoreCase("del") ||
action.equalsIgnoreCase("delete"))
deleteProduct();
else if (action.equalsIgnoreCase("help") ||
action.equalsIgnoreCase("menu"))
displayMenu();
else if (action.equalsIgnoreCase("exit"))
System.out.println("Bye.\n");
else
System.out.println("Error! Not a valid command.\n");
}
}
ProductMaintApp updateProduct = new ProductMaintApp();
private static void updateProduct()
{
ProductMaintApp.updateProduct();
}
public static void displayMenu()
{
System.out.println("COMMAND MENU");
System.out.println("list - List all products");
System.out.println("add - Add a product");
System.out.println("update - Update a product");
System.out.println("del - Delete a product");
System.out.println("help - Show this menu");
System.out.println("exit - Exit this application\n");
}
public static void displayAllProducts()
{
System.out.println("PRODUCT LIST");
System.out.println(productDAO.getProductsString());
}
public static void addProduct()
{
String code = Validator.getString(
sc, "Enter product code: ");
String description = Validator.getLine(
sc, "Enter product description: ");
double price = Validator.getDouble(
sc, "Enter price: ");
Product product = new Product();
product.setCode(code);
product.setDescription(description);
product.setPrice(price);
productDAO.addProduct(product);
System.out.println();
System.out.println(description
+ " has been added.\n");
}
public static void deleteProduct()
{
String code = Validator.getString(sc,
"Enter product code to delete: ");
Product p = productDAO.getProduct(code);
System.out.println();
if (p != null)
{
productDAO.deleteProduct(p);
System.out.println(p.getDescription()
+ " has been deleted.\n");
}
else
{
System.out.println("No product matches that product code.\n");
}
}
}
Posted 24 June 2009 - 09:43 AM
Posted 24 June 2009 - 03:14 PM
nick2price, on 24 Jun, 2009 - 08:43 AM, said:
import java.util.Scanner;
public class ProductMaintApp
{
// declare two class variables
private static ProductDAO productDAO = null;
private static Scanner sc = null;
private static String code;
private static String description;
private static double price;
public static void main(String args[])
{
System.out.println("Welcome to the Product Maintenance application\n");
// set the class variables
productDAO = DAOFactory.getProductDAO();
sc = new Scanner(System.in);
// display the command menu
displayMenu();
// perform 1 or more actions
String action = "";
while (!action.equalsIgnoreCase("exit"))
{
// get the input from the user
action = Validator.getString(sc,
"Enter a command: ");
System.out.println();
if (action.equalsIgnoreCase("list"))
displayAllProducts();
else if (action.equalsIgnoreCase("add"))
addProduct();
else if (action.equalsIgnoreCase("update"))
updateProduct();
else if (action.equalsIgnoreCase("del") ||
action.equalsIgnoreCase("delete"))
deleteProduct();
else if (action.equalsIgnoreCase("help") ||
action.equalsIgnoreCase("menu"))
displayMenu();
else if (action.equalsIgnoreCase("exit"))
System.out.println("Bye.\n");
else
System.out.println("Error! Not a valid command.\n");
}
}
private static void updateProduct()
{
}
public static void displayMenu()
{
System.out.println("COMMAND MENU");
System.out.println("list - List all products");
System.out.println("add - Add a product");
System.out.println("update - Update a product");
System.out.println("del - Delete a product");
System.out.println("help - Show this menu");
System.out.println("exit - Exit this application\n");
}
public static void displayAllProducts()
{
System.out.println("PRODUCT LIST");
System.out.println(productDAO.getProductsString());
}
public static void addProduct()
{
String code = Validator.getString(
sc, "Enter product code: ");
String description = Validator.getLine(
sc, "Enter product description: ");
double price = Validator.getDouble(
sc, "Enter price: ");
Product product = new Product();
product.setCode(code);
product.setDescription(description);
product.setPrice(price);
productDAO.addProduct(product);
System.out.println();
System.out.println(description
+ " has been added.\n");
}
public static void deleteProduct()
{
String code = Validator.getString(sc,
"Enter product code to delete: ");
Product p = productDAO.getProduct(code);
System.out.println();
if (p != null)
{
productDAO.deleteProduct(p);
System.out.println(p.getDescription()
+ " has been deleted.\n");
}
else
{
System.out.println("No product matches that product code.\n");
}
}
public static void setDescription(String description) {
ProductMaintApp.description = description;
}
public static String getDescription() {
return description;
}
public static void setCode(String code) {
ProductMaintApp.code = code;
}
public static String getCode() {
return code;
}
public static void setPrice(double price) {
ProductMaintApp.price = price;
}
public static double getPrice() {
return price;
}
}
Posted 24 June 2009 - 03:22 PM
Posted 24 June 2009 - 03:43 PM
Posted 24 June 2009 - 03:54 PM
productDAO.updateProduct(); //might need to pass it somthing but i cant tell unless i see the class
Posted 24 June 2009 - 06:16 PM
nick2price, on 24 Jun, 2009 - 02:54 PM, said:
productDAO.updateProduct(); //might need to pass it somthing but i cant tell unless i see the class
public interface ProductDAO extends ProductReader, ProductWriter, ProductConstants
{
// all methods from the ProductReader and ProductWriter interfaces
// all static constants from the DAOConstants interface
}
This post has been edited by rollsroyce: 24 June 2009 - 06:18 PM
|
|
Query failed: connection to localhost:3312 failed (errno=111, msg=Connection refused).
|
