Question
create table transactionDetails( transDetailId bigint not null primary key auto_increment, transId bigint not null, itemId int not null, qty int not null, constraint fk_transactionDetails_transId_transactions foreign
create table transactionDetails(
transDetailId bigint not null primary key auto_increment,
transId bigint not null,
itemId int not null,
qty int not null,
constraint fk_transactionDetails_transId_transactions foreign key (transId)
references transactions (transId),
constraint fk_transactionDetails_transId_items foreign key (itemId)
references items (itemId)
);
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package tma02.pos; import java.io.*; import java.net.*;
public class POSClient{ //1. Declare variables private static Socket skt; private static BufferedReader br, in; private static PrintWriter out;
public static void main(String args[]){ String cmd = "";
try{ /* You can ignore this part. This is to flush the File output stream and close the stream when this program close */ Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { try{ out.close(); in.close(); br.close(); skt.close(); }catch(Exception e){ System.out.println("Connection Closed"); } } });
//2. Instantize variables declared in 1
//3. How to instantize a thread class and run it?
/* 4. How to continuously get user input? Assign the input to variable "cmd" */{ //5. How to send the variable "cmd" to server?
//This one is a gift for you, when press "Q", break the loop of Questions-4 if(cmd.equals("Q")){ break; } }//end of loop
//6. Close all the connection and socket }catch(Exception e){ System.out.println("Connection Closed"); }//end of try-catch block }//end of main program }
//3. Create a multithreading class that handle server side input class InputHandler /* 3a. how to make this class multithreading? */{ //3b. Declare a variable that can read line from server
public InputHandler(/* 3c. What Kind of variable it should be pass from main program? */){ //3d. Assign the input parameter to the variable in 3b }
public void /* 3e. What is this method? */{ try{ /* 3f. How to continuously get the message returned from server? */{ System.out.println(/* 3g. How to read line from server? */); }//end of loop }catch(Exception e){ System.out.println("Connection Closed"); }//end of try-catch block } }
8) Click "Detail" button of that row. It should redirect to a page, showing 3 records. Each row shows the item input in step 5. run: C Client Id : 2 R:123:2 R: 456:2 R:999:2 R:AAA:2 Invalid Command X 31.56 Connection Closed BUILD SUCCESSFUL (total time: 25 seconds) Items - Transactions Transaction id Client id Transaction Date Time of items Total Amount 1 1 2020-12-06 17:56:32.0 6 Details 2020-12-13 02:02:14.0 31.560000000002 Details Items Transactions Item Code Item Name Unit Price 123 123
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