-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
dmitriikankan
committed
Nov 4, 2023
1 parent
65f5560
commit da39a7b
Showing
7 changed files
with
831 additions
and
930 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
export class Employee { | ||
private theName: string; | ||
private theHireDate: string; | ||
private aPosition: string; | ||
private aSalary: number; | ||
private anEmail: string; | ||
private aPhoneNumber: string; | ||
|
||
|
||
static employeeCount = 0; | ||
constructor(name: string = 'Не указано', position: string = 'Не указана', hireDate: string = 'Не указана', email: string = 'Не указана', phoneNumber: string = 'Не указан', salary: number = 0) { | ||
this.theName = name; | ||
this.theHireDate = hireDate; | ||
this.aPosition = position; | ||
this.aSalary = salary; | ||
this.anEmail = email; | ||
this.aPhoneNumber = phoneNumber; | ||
Employee.employeeCount += 1; | ||
|
||
} | ||
set salary(salary: number){ | ||
this.aSalary = salary; | ||
} | ||
|
||
get salary(): number{ | ||
return this.aSalary | ||
} | ||
|
||
set position(position: string){ | ||
this.aPosition = position; | ||
} | ||
|
||
get position(): string{ | ||
return this.aPosition; | ||
} | ||
|
||
set email(email: string){ | ||
this.anEmail = email; | ||
} | ||
|
||
get email(): string{ | ||
return this.anEmail; | ||
} | ||
|
||
set phoneNumber(phoneNumber: string){ | ||
this.aPhoneNumber = phoneNumber; | ||
} | ||
|
||
get phoneNumber(): string{ | ||
return this.aPhoneNumber; | ||
} | ||
get name(): string{ | ||
return this.theName | ||
} | ||
|
||
get hireDate(): string{ | ||
return this.theHireDate | ||
} | ||
|
||
getInfo(): string { | ||
return `ФИО: ${this.theName}; Должность: ${this.aPosition}; Дата приема на работу: ${this.theHireDate}; Заработная плата: ${this.aSalary} рублей; E-mail: ${this.anEmail}; Номер телефона: ${this.aPhoneNumber}.` | ||
} | ||
|
||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
import { Phone } from './phone'; | ||
import { Employee } from './employee'; | ||
|
||
const first = new Phone('+7900-000 000 (123)', 1990, 'Телефон 1'); | ||
first.year = 1998; | ||
const employee1 = new Employee('Буянов Никита Васильвич', 'PR-менеджер', '15 октября 2014'); | ||
|
||
first.year = -1998; | ||
first.call('12345'); | ||
first.endCall(); | ||
employee1.position = 'Аналитик'; | ||
employee1.salary = 100000; | ||
employee1.email = '[email protected]' | ||
|
||
const second = new Phone('+799900000', -5); | ||
// second.name = 'Телефон 2'; | ||
console.log(second.year); | ||
second.call('12345'); | ||
second.endCall(); | ||
const employee2 = new Employee('Дмитриев Иван Иванович', 'Тестировщик', '26 ноября 2014'); | ||
|
||
console.log(first, second, Phone.phoneCount); | ||
employee2.position = 'Разработчики'; | ||
employee2.salary = 240000; | ||
employee2.phoneNumber = '+7915-323-00-00' | ||
|
||
const employee3 = new Employee(undefined, undefined, '15 октября 2014', '[email protected]', '+7915-323-00-00', 100000); | ||
|
||
console.log(employee1.getInfo()) | ||
console.log(employee2.getInfo()) | ||
console.log(employee3.getInfo()) | ||
console.log(`Количество сотрудников: ${Employee.employeeCount}`) |
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Employee } from '../src/employee'; | ||
|
||
describe('Testing employee constructor', () => { | ||
it('Employee should be created', () => { | ||
const employee1 = new Employee('Буянов Никита Васильвич', 'PR-менеджер', '15 октября 2014', '[email protected]', '+7915-323-00-00', 100000); | ||
expect(employee1.name).toEqual('Буянов Никита Васильвич'); | ||
expect(employee1.position).toEqual('PR-менеджер'); | ||
expect(employee1.hireDate).toEqual('15 октября 2014'); | ||
expect(employee1.email).toEqual('[email protected]'); | ||
expect(employee1.phoneNumber).toEqual('+7915-323-00-00'); | ||
expect(employee1.salary).toEqual(100000); | ||
}); | ||
}); | ||
|
||
describe('Testing employee methods', () => { | ||
it('Employee new position value', () => { | ||
const employee1 = new Employee('Буянов Никита Васильвич', 'PR-менеджер', '15 октября 2014', '[email protected]', '+7915-323-00-00', 100000); | ||
employee1.position = 'Аналитик'; | ||
expect(employee1.position).toEqual('Аналитик'); | ||
}); | ||
it('Employee new email value', () => { | ||
const employee1 = new Employee('Буянов Никита Васильвич', 'PR-менеджер', '15 октября 2014', '[email protected]', '+7915-323-00-00', 100000); | ||
employee1.email = '[email protected]' | ||
expect(employee1.email).toEqual('[email protected]'); | ||
}); | ||
it('Employee new phone number value', () => { | ||
const employee1 = new Employee('Буянов Никита Васильвич', 'PR-менеджер', '15 октября 2014', '[email protected]', '+7915-323-00-00', 100000); | ||
employee1.phoneNumber = '+7920-363-33-33'; | ||
expect(employee1.phoneNumber).toEqual('+7920-363-33-33'); | ||
}); | ||
it('Employee new salary value', () => { | ||
const employee1 = new Employee('Буянов Никита Васильвич', 'PR-менеджер', '15 октября 2014', '[email protected]', '+7915-323-00-00', 100000); | ||
employee1.salary = 2000000; | ||
expect(employee1.salary).toEqual(2000000); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.