Design a class named StockTransaction that holds a stock symbol (typically one to four characters), stock name, number of shares traded, and price per share. Include methods to set and get the values for each data field. Create the class diagram using UMLet and write the pseudocode that defines the class.

Here is the UML class diagram for the StockTransaction class:

```
---------------------------------
| StockTransaction |
---------------------------------
| - symbol: String |
| - name: String |
| - shares: int |
| - pricePerShare: double |
---------------------------------
| + setSymbol(symbol: String) |
| + getSymbol(): String |
| + setName(name: String) |
| + getName(): String |
| + setShares(shares: int) |
| + getShares(): int |
| + setPricePerShare(price: double) |
| + getPricePerShare(): double |
---------------------------------
```

And here is the pseudocode for the StockTransaction class:

```
class StockTransaction:
private symbol: string
private name: string
private shares: int
private pricePerShare: double

method setSymbol(symbol: string):
this.symbol = symbol

method getSymbol(): string:
return this.symbol

method setName(name: string):
this.name = name

method getName(): string:
return this.name

method setShares(shares: int):
this.shares = shares

method getShares(): int:
return this.shares

method setPricePerShare(price: double):
this.pricePerShare = price

method getPricePerShare(): double:
return this.pricePerShare
```

This pseudocode defines the StockTransaction class with the required data fields and methods to set and get their values. The data fields are set to private to encapsulate them and ensure controlled access to the data. The set methods allow assigning values to the data fields, and the get methods return the values of the data fields when called.

To design the StockTransaction class, we will follow the steps below:

Step 1: Identify the attributes of the class:
- stockSymbol : string
- stockName : string
- numberOfShares : integer
- pricePerShare : double

Step 2: Identify the methods of the class:
- setStockSymbol(symbol: string) : void
- getStockSymbol() : string
- setStockName(name: string) : void
- getStockName() : string
- setNumberOfShares(number: integer) : void
- getNumberOfShares() : integer
- setPricePerShare(price: double) : void
- getPricePerShare() : double

Step 3: Create the class diagram using UMLet. Here is the UML representation:

```
+--------------------------------+
| StockTransaction |
+--------------------------------+
| - stockSymbol : string |
| - stockName : string |
| - numberOfShares : integer |
| - pricePerShare : double |
+--------------------------------+
| + setStockSymbol(symbol: string) |
| + getStockSymbol() : string |
| + setStockName(name: string) |
| + getStockName() : string |
| + setNumberOfShares(number: integer)|
| + getNumberOfShares() : integer |
| + setPricePerShare(price: double) |
| + getPricePerShare() : double |
+--------------------------------+
```

Step 4: Write the pseudocode that defines the StockTransaction class:

```
class StockTransaction
private variables:
- stockSymbol : string
- stockName : string
- numberOfShares : integer
- pricePerShare : double

public methods:
- setStockSymbol(symbol: string) : void
stockSymbol = symbol

- getStockSymbol() : string
return stockSymbol

- setStockName(name: string) : void
stockName = name

- getStockName() : string
return stockName

- setNumberOfShares(number: integer) : void
numberOfShares = number

- getNumberOfShares() : integer
return numberOfShares

- setPricePerShare(price: double) : void
pricePerShare = price

- getPricePerShare() : double
return pricePerShare
```

That's it! You have designed the StockTransaction class, created its class diagram using UMLet, and written the pseudocode that defines the class.

8562

3