Develop an inventory management system for an electronics store. The inventory system should
have the following functionalities .BuildInventory: reada text file containing electronics products
information and store them in an array of pointers .Shownventory display all inventory items
.ShowDefectInventory: display inventory items that are defective Terminate: to save cument
inventory to a text file This lab assignment illustrates the following concepts: -Text file readings
and writings .Arrays of pointers and dynamic memory allocations with new and delete
Inheritance .C++ type casting: static cast Class Design You need at least three classes class
Inventory System: (minimum implementation specified below). This class stores Inyentoryltem
objects (which are in fact Inventory item base class pointers to derived Product objects and
member functions to manipulate those Product objects as shown below. .Private data members
Store Name Store ID ltem List (array of pointers to Inventory Item objects, max of 512) ltem
Count (tracking how many items are currently stored in the array) .Constructors (initialize all
pointers in the array to NULL in addition to what's described below .Default constructor: set
data members to 0 (for integers), 0.0 (for float/double), or NULL (for pointers) as appropriate.
Also invoke this function to initialize a seed for the random generator srand (time (NULL), (to
be used later by Product class to genearte random values for Product ID. See Code Helper
section at the end of the lab specs.) .Non-default constructor: taking a string for store name, an
integer for store ID. Call srand as shown above Destructor: de-allocate dynamic memory in the
amay off pointers (up to Item Count elements) .Public member functions: BuildInventory: read a
text file containing Product records (one Product per line), dynamically allocate Product objects
and store the objects in the array ItemList (an array of Inventoryltem pointers). It should also
update Item Count as needed Shownventory: display all Products in the inventory. Output must
be properly formatted and aligned (usingfield with and floating data with 2 digits after decimal
point). Note that if you invoke the Display function using the pointers from the array only Invent
tem (base objec) information will be displayed. Extra work is needed to properly display
Products (derived objects) information ntory: display only defective Products Terminate: iterate
thru the array of pointers to write Product objects in the array to a text file in the same format as
they were read in. You may use a different file name for wniting .mutator cessors for store name,
store id, and item count
Solution
/*
import com.incors.plaf.*;
import com.incors.plaf.kunststoff.*;
import com.incors.plaf.kunststoff.themes.*;
*/
public class MainForm extends JFrame implements WindowListener{
/************************ Variable declaration start **********************/
//The form container variable
JPanel Panel1;
JDesktopPane Desk1 = new JDesktopPane();
JLabel StatusLabel = new JLabel("Copyright © 2004 by Philip V. Naparan. All Rights
Reserved. Visit http://www.naparansoft.cjb.net.",JLabel.CENTER);
JLabel BusinessTitleLabel = new JLabel();
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
String StrBusinesTitle;
String DBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String DBSource = "jdbc:odbc:NaparansoftInventory";
String DBUserName = "Admin";
String DBPassword = "philip121";
Connection CN;
//--Start variable the contains forms
FrmCustomer FormCustomer;
FrmSupplier FormSupplier;
FrmSalesRep FormSalesRep;
FrmWarehouse FormWarehouse;
FrmProduct FormProduct;
FrmInvoice FormInvoice;
FrmSplash FormSplash = new FrmSplash();
//--End variable the contains forms
Thread ThFormSplash = new Thread(FormSplash);
//End the form container variable
/********************** End variable declaration start ********************/
/************************ MainForm constructor start **********************/
public MainForm(){
//Set the main form title
super("Naparansoft Inventory System version 1.1");
//End set the main form title
loadSplashScreen();
//We will dispose now the FormSplash because it is now useless
FormSplash.dispose();
//StatusLabel.setBorder(BorderFactory.createTitledBorder(""));
StatusLabel.setFont(new Font("Dialog", Font.PLAIN, 12));
StrBusinesTitle = "Your Business Name";
BusinessTitleLabel.setText(StrBusinesTitle);
BusinessTitleLabel.setHorizontalAlignment(JLabel.LEFT);
BusinessTitleLabel.setForeground(new Color(166,0,0));
//Set the main form properties
addWindowListener(this);
Desk1.setBackground(Color.gray);
Desk1.setBorder(BorderFactory.createEmptyBorder());
//Most fastest drag mode
Desk1.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
Panel1 = new JPanel(new BorderLayout());
Panel1.setBackground(Color.gray);
Panel1.setBorder(BorderFactory.createLoweredBevelBorder());
Panel1.add(new JScrollPane(Desk1),BorderLayout.CENTER);
getContentPane().add(CreateJToolBar(),BorderLayout.PAGE_START);
getContentPane().add(Panel1,BorderLayout.CENTER);
getContentPane().add(StatusLabel,BorderLayout.PAGE_END);
setJMenuBar(CreateJMenuBar());
setExtendedState(this.MAXIMIZED_BOTH);
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
setIconImage(new ImageIcon("images/appicon.png").getImage());
setLocation(0,0);
setSize(screen);
setResizable(true);
setVisible(true);
show();
try{
Class.forName(DBDriver);
CN = DriverManager.getConnection(DBSource,DBUserName ,DBPassword);
}catch(ClassNotFoundException e) {
System.err.println("Failed to load driver");
e.printStackTrace();
System.exit(1);
}
catch(SQLException e){
System.err.println("Unable to connect");
e.printStackTrace();
System.exit(1);
}
//End set the main form properties
}
/********************** End MainForm constructor start ********************/
/*********************** Custom class creation start **********************/
//Create menu bar
protected JMenuBar CreateJMenuBar(){
JMenuBar NewJMenuBar = new JMenuBar();
//Setup file menu
JMenu MnuFile = new JMenu("File");
MnuFile.setFont(new Font("Dialog", Font.PLAIN, 12));
MnuFile.setMnemonic('F');
MnuFile.setBackground(new Color(255,255,255));
NewJMenuBar.add(MnuFile);
//End setup file menu
//Set file sub menu
JMenuItem ItmLockApp = new JMenuItem("lock Application");
ItmLockApp.setFont(new Font("Dialog", Font.PLAIN, 12));
ItmLockApp.setMnemonic('L');
ItmLockApp.setIcon(new ImageIcon("images/lockapplication.png"));
ItmLockApp.setAccelerator(
KeyStroke.getKeyStroke(
KeyEvent.VK_L,ActionEvent.CTRL_MASK
)
);
ItmLockApp.setActionCommand("lockapp");
ItmLockApp.addActionListener(JMenuActionListener);
ItmLockApp.setBackground(new Color(255,255,255));
JMenuItem ItmLoggOff = new JMenuItem("Logg Off");
ItmLoggOff.setFont(new Font("Dialog", Font.PLAIN, 12));
ItmLoggOff.setMnemonic('O');
ItmLoggOff.setIcon(new ImageIcon("images/loggoff.png"));
ItmLoggOff.setAccelerator(
KeyStroke.getKeyStroke(
KeyEvent.VK_O,ActionEvent.CTRL_MASK
)
);
ItmLoggOff.setActionCommand("loggoff");
ItmLoggOff.addActionListener(JMenuActionListener);
ItmLoggOff.setBackground(new Color(255,255,255));
JMenuItem ItmExit = new JMenuItem("Exit");
ItmExit.setFont(new Font("Dialog", Font.PLAIN, 12));
ItmExit.setMnemonic('E');
ItmExit.setIcon(new ImageIcon("images/exit.png"));
ItmExit.setAccelerator(
KeyStroke.getKeyStroke(
KeyEvent.VK_E,ActionEvent.CTRL_MASK
)
);
ItmExit.setActionCommand("exit");
ItmExit.addActionListener(JMenuActionListener);
ItmExit.setBackground(new Color(255,255,255));
MnuFile.add(ItmLockApp);
MnuFile.addSeparator();
MnuFile.add(ItmLoggOff);
MnuFile.add(ItmExit);
//End set file sub menu
//Setup records menu
JMenu MnuRec = new JMenu("Records");
MnuRec.setFont(new Font("Dialog", Font.PLAIN, 12));
MnuRec.setMnemonic('R');

Develop an inventory management system for an electronics store. The .pdf

  • 1.
    Develop an inventorymanagement system for an electronics store. The inventory system should have the following functionalities .BuildInventory: reada text file containing electronics products information and store them in an array of pointers .Shownventory display all inventory items .ShowDefectInventory: display inventory items that are defective Terminate: to save cument inventory to a text file This lab assignment illustrates the following concepts: -Text file readings and writings .Arrays of pointers and dynamic memory allocations with new and delete Inheritance .C++ type casting: static cast Class Design You need at least three classes class Inventory System: (minimum implementation specified below). This class stores Inyentoryltem objects (which are in fact Inventory item base class pointers to derived Product objects and member functions to manipulate those Product objects as shown below. .Private data members Store Name Store ID ltem List (array of pointers to Inventory Item objects, max of 512) ltem Count (tracking how many items are currently stored in the array) .Constructors (initialize all pointers in the array to NULL in addition to what's described below .Default constructor: set data members to 0 (for integers), 0.0 (for float/double), or NULL (for pointers) as appropriate. Also invoke this function to initialize a seed for the random generator srand (time (NULL), (to be used later by Product class to genearte random values for Product ID. See Code Helper section at the end of the lab specs.) .Non-default constructor: taking a string for store name, an integer for store ID. Call srand as shown above Destructor: de-allocate dynamic memory in the amay off pointers (up to Item Count elements) .Public member functions: BuildInventory: read a text file containing Product records (one Product per line), dynamically allocate Product objects and store the objects in the array ItemList (an array of Inventoryltem pointers). It should also update Item Count as needed Shownventory: display all Products in the inventory. Output must be properly formatted and aligned (usingfield with and floating data with 2 digits after decimal point). Note that if you invoke the Display function using the pointers from the array only Invent tem (base objec) information will be displayed. Extra work is needed to properly display Products (derived objects) information ntory: display only defective Products Terminate: iterate thru the array of pointers to write Product objects in the array to a text file in the same format as they were read in. You may use a different file name for wniting .mutator cessors for store name, store id, and item count Solution /* import com.incors.plaf.*; import com.incors.plaf.kunststoff.*;
  • 2.
    import com.incors.plaf.kunststoff.themes.*; */ public classMainForm extends JFrame implements WindowListener{ /************************ Variable declaration start **********************/ //The form container variable JPanel Panel1; JDesktopPane Desk1 = new JDesktopPane(); JLabel StatusLabel = new JLabel("Copyright © 2004 by Philip V. Naparan. All Rights Reserved. Visit http://www.naparansoft.cjb.net.",JLabel.CENTER); JLabel BusinessTitleLabel = new JLabel(); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); String StrBusinesTitle; String DBDriver = "sun.jdbc.odbc.JdbcOdbcDriver"; String DBSource = "jdbc:odbc:NaparansoftInventory"; String DBUserName = "Admin"; String DBPassword = "philip121"; Connection CN; //--Start variable the contains forms FrmCustomer FormCustomer; FrmSupplier FormSupplier; FrmSalesRep FormSalesRep; FrmWarehouse FormWarehouse; FrmProduct FormProduct; FrmInvoice FormInvoice; FrmSplash FormSplash = new FrmSplash(); //--End variable the contains forms Thread ThFormSplash = new Thread(FormSplash); //End the form container variable /********************** End variable declaration start ********************/ /************************ MainForm constructor start **********************/ public MainForm(){ //Set the main form title super("Naparansoft Inventory System version 1.1"); //End set the main form title
  • 3.
    loadSplashScreen(); //We will disposenow the FormSplash because it is now useless FormSplash.dispose(); //StatusLabel.setBorder(BorderFactory.createTitledBorder("")); StatusLabel.setFont(new Font("Dialog", Font.PLAIN, 12)); StrBusinesTitle = "Your Business Name"; BusinessTitleLabel.setText(StrBusinesTitle); BusinessTitleLabel.setHorizontalAlignment(JLabel.LEFT); BusinessTitleLabel.setForeground(new Color(166,0,0)); //Set the main form properties addWindowListener(this); Desk1.setBackground(Color.gray); Desk1.setBorder(BorderFactory.createEmptyBorder()); //Most fastest drag mode Desk1.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); Panel1 = new JPanel(new BorderLayout()); Panel1.setBackground(Color.gray); Panel1.setBorder(BorderFactory.createLoweredBevelBorder()); Panel1.add(new JScrollPane(Desk1),BorderLayout.CENTER); getContentPane().add(CreateJToolBar(),BorderLayout.PAGE_START); getContentPane().add(Panel1,BorderLayout.CENTER); getContentPane().add(StatusLabel,BorderLayout.PAGE_END); setJMenuBar(CreateJMenuBar()); setExtendedState(this.MAXIMIZED_BOTH); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); setIconImage(new ImageIcon("images/appicon.png").getImage()); setLocation(0,0); setSize(screen); setResizable(true); setVisible(true); show(); try{ Class.forName(DBDriver); CN = DriverManager.getConnection(DBSource,DBUserName ,DBPassword); }catch(ClassNotFoundException e) { System.err.println("Failed to load driver");
  • 4.
    e.printStackTrace(); System.exit(1); } catch(SQLException e){ System.err.println("Unable toconnect"); e.printStackTrace(); System.exit(1); } //End set the main form properties } /********************** End MainForm constructor start ********************/ /*********************** Custom class creation start **********************/ //Create menu bar protected JMenuBar CreateJMenuBar(){ JMenuBar NewJMenuBar = new JMenuBar(); //Setup file menu JMenu MnuFile = new JMenu("File"); MnuFile.setFont(new Font("Dialog", Font.PLAIN, 12)); MnuFile.setMnemonic('F'); MnuFile.setBackground(new Color(255,255,255)); NewJMenuBar.add(MnuFile); //End setup file menu //Set file sub menu JMenuItem ItmLockApp = new JMenuItem("lock Application"); ItmLockApp.setFont(new Font("Dialog", Font.PLAIN, 12)); ItmLockApp.setMnemonic('L'); ItmLockApp.setIcon(new ImageIcon("images/lockapplication.png")); ItmLockApp.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_L,ActionEvent.CTRL_MASK ) ); ItmLockApp.setActionCommand("lockapp"); ItmLockApp.addActionListener(JMenuActionListener); ItmLockApp.setBackground(new Color(255,255,255)); JMenuItem ItmLoggOff = new JMenuItem("Logg Off");
  • 5.
    ItmLoggOff.setFont(new Font("Dialog", Font.PLAIN,12)); ItmLoggOff.setMnemonic('O'); ItmLoggOff.setIcon(new ImageIcon("images/loggoff.png")); ItmLoggOff.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_O,ActionEvent.CTRL_MASK ) ); ItmLoggOff.setActionCommand("loggoff"); ItmLoggOff.addActionListener(JMenuActionListener); ItmLoggOff.setBackground(new Color(255,255,255)); JMenuItem ItmExit = new JMenuItem("Exit"); ItmExit.setFont(new Font("Dialog", Font.PLAIN, 12)); ItmExit.setMnemonic('E'); ItmExit.setIcon(new ImageIcon("images/exit.png")); ItmExit.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_E,ActionEvent.CTRL_MASK ) ); ItmExit.setActionCommand("exit"); ItmExit.addActionListener(JMenuActionListener); ItmExit.setBackground(new Color(255,255,255)); MnuFile.add(ItmLockApp); MnuFile.addSeparator(); MnuFile.add(ItmLoggOff); MnuFile.add(ItmExit); //End set file sub menu //Setup records menu JMenu MnuRec = new JMenu("Records"); MnuRec.setFont(new Font("Dialog", Font.PLAIN, 12)); MnuRec.setMnemonic('R');