Method

Description

Critical Questions Associated with This Method

public Transaction(Stock s)

Transaction constructor which sets s to the variable made tStock

Q.1

protected void buy(double c)

This protected method is for purchasing stocks. When stock is bought it is ran through a number of if statements that allocates and set the available money to spend per buy transactions. The number of shares is set and if there is not enough money available in the wallet the user is presented with an “insufficient funds”.

Q.2

protected void sell(double c, int q, double purch, String t)

This method is for selling stocks. It retrieves the stock name and calculates total cost of the stock. The cash is then updated within the wallet based on transaction.

protected void hold()

When the decision is made hold a stock the name of the stock is returned and the variable held is set to true this holding the stock.

protected void log(String t, String sym, double p, int qty, double total)

This method records all data within transactions. It records the time, date, and year and also the name of the stock. This includes: symbol of the stock, current price, percent change, and the quantity of each stock which is all added to the portfolio.

Q.2

private static void p(String s)

Private method that is used for printing the variable s which is made within the constructor above in the class

public void updateTable(String query)

This method updates table which is connected to the database and is made to return the necessary data. If statements check connection.

Q.1, Q.2, Q.3