1) Let us suppose you are implementing file system. This file system contains folders and files. A folder can contain other folders and files. Provide a very simple implementation using an OOP for this simple file system using a composite design pattern. Folders and Files have just one common attribute: its name.
Create a client object that can via methods:
• print file/folder names
• Add files/folders to a folder
• Remove files from a folder
2) Final project
Instructions:
This project is using purescript programming language.
You must provide presentation about your proof-of-concept.
Provide complete instruction indicating how to execute your code
You must also create a 5min video presenting your demo.
Objectives
This is your final project. This project is a banking application simulation of key account management functionalities such as deposit, withdrawal, and statement printing.
The objective of the project is to showcase how bank software developers can build functionalities for withdrawing, depositing, and printing account statements.
Steps involved:
i. Installing the Purescript compiler (purs) with npm:
npm install -g purescript
ii. Setting up the Development Environment with spago
npm install -g spago
iii. Creating a new project in an empty directory using spago init:
mkdir my-project
cd my-project
spago init
spago build
spago test
a. Constraints
The following are key functions implemented in the program.
void deposit(int) – an impure function that accepts int as the amount to be deposited into the account.
void withdraw(int) – an impure function that accepts an int as the amount that will be withdrawn from the account.
String printStatement() – an impure function that prints and returns the account history based on withdrawals and deposits done on the account.
b. Features
• Deposit money into an account
• Withdraw money from an account
• Print Account Statement
c. Technology you used
The tools and technologies used in this project include:
• Visual studio code
• Purescript compiler
• Spango which is a build system for purescirpt
• Html
• Javascritpt
• Dhal
e. Where this project can be applied
This project can be applied in financial technology and banking industries.
Code Snippets
#Main.purs
module Main where
import Prelude
data Transaction
= Deposit Info
| Withdraw Info
derive instance eqTransaction :: Eq Transaction
instance showTransaction :: Show Transaction where
show (Deposit i) = show i
show (Withdraw i) = show i
type Info =
{ timestamp :: DateTime
, amount :: Int
}
deposit :: forall m. Monad m => m DateTime -> Int -> StateT (Array Transaction) m Unit
deposit nowDateTime amount = do
ts <- lift nowDateTime
let t = Deposit { timestamp: ts, amount: amount }
modify_ \ts -> ts <> [t]
withdraw :: forall m. Monad m => m DateTime -> Int -> StateT (Array Transaction) m Unit
withdraw nowDateTime amount = do
ts <- lift nowDateTime
let t = Withdraw { timestamp: ts, amount: amount }
modify_ \ts -> ts <> [t]
printStatement :: forall m. Monad m => (String -> m Unit) -> StateT (Array Transaction) m Unit
printStatement logger = do
s <- gets toStatement
lift $ logger s
toStatement :: Array Transaction -> String
toStatement =
fst <<< foldl fnc (Tuple “” 0)
where
fnc (Tuple s i) (Deposit d) =
Tuple (s <> “\n” <> joinWith ” ” [ show d.timestamp, show d.amount, show $ i + d.amount]) (i + d.amount)
fnc (Tuple s i) (Withdraw w) =
Tuple (s <> “\n” <> joinWith ” ” [ show w.timestamp, “-” <> show w.amount, show $ i – w.amount]) (i – w.amount)