Skip to content

Commit

Permalink
rabbit
Browse files Browse the repository at this point in the history
  • Loading branch information
AlyonaUi committed Oct 23, 2023
1 parent b819e7a commit 15dd596
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 14 deletions.
21 changes: 7 additions & 14 deletions rpgsaga/saga/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import { Phone } from './phone';
import { Rabbit } from './rabbit';

const first = new Phone('+7900-000 000 (123)', 1990, 'Телефон 1');
first.year = 1998;
const myRabbit = new Rabbit(5, 'black', 'Dutch dwarf');
myRabbit.age = 10;
console.log(myRabbit.age);
myRabbit.name = 'Malebu';
console.log(myRabbit.name);

first.year = -1998;
first.call('12345');
first.endCall();

const second = new Phone('+799900000', -5);
// second.name = 'Телефон 2';
console.log(second.year);
second.call('12345');
second.endCall();

console.log(first, second, Phone.phoneCount);
console.log(myRabbit);
32 changes: 32 additions & 0 deletions rpgsaga/saga/src/rabbit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
export class Rabbit {
private _age: number;
private breed: string;
private color: string;
private _name: string;

constructor(rabAge: number, rabBreed: string, rabColor: string) {
this.age = rabAge;
this.breed = rabBreed;
this.color = rabColor;
}

get age(): number {
return this._age;
}

set age(n: number) {
if (n < 0 || n > 12) {
console.log('Недопустимый возраст!');
} else {
this._age = n;
}
}

get name(): string {
return this._name;
}

public set name(str: string) {
this._name = str;
}
}
1 change: 1 addition & 0 deletions rpgsaga/saga/tests/rabbit.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import { Rabbit } from '../src/rabbit';

0 comments on commit 15dd596

Please sign in to comment.