Skip to content

Commit

Permalink
fix lint sp
Browse files Browse the repository at this point in the history
  • Loading branch information
holenyt committed Dec 7, 2024
1 parent 9aa009f commit 0c04ebb
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 48 deletions.
16 changes: 8 additions & 8 deletions rpgsaga/saga/src/Customer.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Person } from "./Person";
import { Person } from './Person';

export class Customer extends Person {
toString() {
return 'У Customer toString() переопределён';
}
come(): void {
console.log(`${this.name} пришёл домой`);
}
}
toString() {
return 'У Customer toString() переопределён';
}
come(): void {
console.log(`${this.name} пришёл домой`);
}
}
10 changes: 4 additions & 6 deletions rpgsaga/saga/src/Employee.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Person } from "./Person";
import { Person } from './Person';

export class Employee extends Person {
private _salary: number;
Expand All @@ -9,7 +9,6 @@ export class Employee extends Person {
this.salary = salary;
}


public get salary(): number {
return this._salary;
}
Expand All @@ -24,15 +23,14 @@ export class Employee extends Person {
console.log(`${this.name} пришёл на работу`);
}
toString(): void {
console.log('У Employee toString() переопределён')
console.log('У Employee toString() переопределён');
}


addYearsOfWorkExperience(years: number): void {
if (years < 0) {
throw new Error('You cannot add negative numbers');
throw new Error('You cannot add negative numbers');
}
this._yearsOfWorkExperience+=years;
this._yearsOfWorkExperience += years;
}
getYearsOfWorkExperience(): number {
return this._yearsOfWorkExperience;
Expand Down
62 changes: 31 additions & 31 deletions rpgsaga/saga/src/Person.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
export abstract class Person {
private _name: string;
private _age: number;
private _sick: boolean;
private _name: string;
private _age: number;
private _sick: boolean;

constructor(name: string, age: number, isSick: boolean = false) {
this._name = name;
this.age = age;
this._sick = isSick;
}
constructor(name: string, age: number, isSick: boolean = false) {
this._name = name;
this.age = age;
this._sick = isSick;
}

abstract come(): void;
abstract toString(): void;
abstract come(): void;
abstract toString(): void;

public get sick(): boolean {
return this._sick;
}
public set sick(isSick: boolean) {
this._sick = isSick;
}
public get sick(): boolean {
return this._sick;
}
public set sick(isSick: boolean) {
this._sick = isSick;
}

public get name(): string {
return this._name;
public get name(): string {
return this._name;
}
public set name(name: string) {
this._name = name;
}
public get age(): number {
return this._age;
}
public set age(age: number) {
if (age < 0) {
throw new Error('Age cannot be negative.');
}
public set name(name: string) {
this._name = name;
}
public get age(): number {
return this._age;
}
public set age(age: number) {
if (age < 0) {
throw new Error('Age cannot be negative.');
}
this._age = age;
}
}
this._age = age;
}
}
5 changes: 2 additions & 3 deletions rpgsaga/saga/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,15 @@ const employee3: Employee = new Employee('Mikhail', 17, 20000);

const customer1: Customer = new Customer('test', 123);

let array: Person[] = [];
const array: Person[] = [];

array.push(employee1);
array.push(employee2);
array.push(customer1);
for (const a of array) {
a.come();
a.come();
}


console.log(employee1);
console.log(employee2);
console.log(employee3);
Expand Down

0 comments on commit 0c04ebb

Please sign in to comment.