This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { DepositContract, LoanContract, InsuranceContract } from '../src/contracts'; | |
describe('DepositContract', () => { | |
const contract = new DepositContract('D001', 'Ivan', true, 10000, 0.05); | |
test('should store fields correctly', () => { | |
expect(contract.contractId).toBe('D001'); | |
expect(contract.clientName).toBe('Ivan'); | |
expect(contract.isActive).toBe(true); | |
expect(contract.amount).toBe(10000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class User { | |
name: string; | |
surname: string; | |
age: number; | |
isConsentGiven: boolean; | |
constructor(name:string, surname:string, age:number) { | |
this.name = name; | |
this.surname = surname; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Multiply #1 | |
export function multiply(a: number, b: number): number { | |
return a * b | |
} | |
//Calculate Percentage #2 | |
export function calculatePercentage(a:number,b:number): number{ | |
return a/b * 100 | |
} | |
//Is even #3 | |
export function isEven(num:number): boolean{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Assignment #1 | |
class Calculator { | |
addition(num1: number, num2: number): number { | |
return num1 + num2; | |
} | |
isGreater(num1: number, num2: number): boolean { | |
return num1 > num2; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Assignment #1 | |
//Temperature Converter | |
function convertToFahrenheit(celsius: number): number { | |
const result = (celsius * 9/5) + 32; | |
return result; | |
} | |
console.log('Converting to Fahrenheit ' + convertToFahrenheit(30)); //Out come 86 | |
console.log('Converting to Fahrenheit ' + convertToFahrenheit(100)); //Out come 212 | |
console.log('Converting to Fahrenheit ' + convertToFahrenheit(-15)); //Out come 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Assignment #1 | |
//Temperature Converter | |
function convertToFahrenheit(celsius: number): number { | |
const result = (celsius * 9/5) + 32; | |
return result; | |
} | |
console.log('Converting to Fahrenheit ' + convertToFahrenheit(30)); //Out come 86 | |
console.log('Converting to Fahrenheit ' + convertToFahrenheit(100)); //Out come 212 | |
console.log('Converting to Fahrenheit ' + convertToFahrenheit(-15)); //Out come 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Task #1 | |
//Declare variables for length and width | |
let variableLength=2; | |
let variableWidth =4; | |
//Declare third variable store to the area | |
let variableStoreArea: number; | |
//Initialize the area | |
variableStoreArea = variableLength*variableWidth; |