Compare commits

..

2 Commits

Author SHA1 Message Date
Костя f2cb6cf6dd add new comments 2025-06-17 13:46:50 +03:00
Костя 25a4e7d988 add comments 2025-06-10 18:47:11 +03:00
6 changed files with 23 additions and 150 deletions

22
.vscode/launch.json vendored
View File

@ -1,22 +0,0 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}\\src\\index.ts",
"outFiles": [
"${workspaceFolder}/**/*.js"
],
"preLaunchTask": "build_backend"
}
]
}

12
.vscode/tasks.json vendored
View File

@ -1,12 +0,0 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build_backend",
"type": "npm",
"script": "build",
"path": "/",
"problemMatcher": []
}
]
}

View File

@ -1,3 +1,7 @@
// ########################## УЧЕБНЫЙ ТЕКСТ ############################################################
//******************************************************************************************************
interface People { interface People {
name: string; name: string;
age: number | undefined; age: number | undefined;
@ -40,6 +44,12 @@ class ProcessingPeoples implements PeopleLocation {
} }
} }
let str: string = 'test text';
let proc1 = new ProcessingPeoples(str)
console.log(proc1)
proc1.name = 'new test'
console.log(proc1)
class ProcessingPeoplesExt extends ProcessingPeoples { class ProcessingPeoplesExt extends ProcessingPeoples {
isActive: boolean = false; isActive: boolean = false;
@ -64,13 +74,16 @@ class Duck {
} }
} }
let Utka: Duck = new Duck();
Utka.log();
interface Eateable { interface Eateable {
eat(): void; eat(): void; //пустота, функция ничего не принимает и не возвращает.
} }
class GreyDuck extends Duck implements Eateable{ class GreyDuck extends Duck implements Eateable{ //наследоваться можно от другого класса только один раз, но!! реализация интерфейсов может быть не ограниченно количество раз
constructor() { constructor() {
super(); super(); // в данном примере, если используется конструктор и при этом этот конструктор наслеедуется от родителя, то мы обязаны вызывать конструктор родителя.
this.type = 'GreyDuck' this.type = 'GreyDuck'
} }
override log(){ override log(){
@ -86,6 +99,7 @@ class RedDuck extends Duck implements Eateable {
constructor() { constructor() {
super(); super();
this.type = 'RedDuck' this.type = 'RedDuck'
console.log(`Object created ${this.type}`)
} }
eat(): void { eat(): void {
console.log("I'm eat"); console.log("I'm eat");
@ -103,6 +117,9 @@ let array: Eateable[] = [
duck2 duck2
]; ];
let result = array[0]; //мы можем проверить содержание массива с именем array. в квадратных скобках мы указали ноль = это первый эелемент массива.
console.log(`результат содержимого массива${JSON.stringify(result)}`); //вывод на экран
for (let item of array) { for (let item of array) {
item.eat(); item.eat();
} }
@ -116,95 +133,5 @@ for (let item of array2) {
item.log(); item.log();
} }
array2.filter(item => "eat" in item); array2.filter(item => "eat" in item); //тестирование не относится к тексту выше
//Обучение ЦИКЛАМ
//lesson 1.5 SUM OF NUMBERS
function CalculateRectangleArea(sideA: number, sideB: number) : number {
return sideA * sideB;
}
//Virtual console
let chisloOne: string = '2';
let chisloTwo: string = 'A';
//Solution
let sideA = Number.parseInt(chisloOne, 10);
let sideB = Number.parseInt(chisloTwo, 10);
// && - AND
// || - OR
// !
if (Number.isNaN(sideA) || sideA <= 0 ){
console.log(`Your first value is invalid: ${sideA}`)
}
if (Number.isNaN(sideB) || sideB <= 0){
console.log(`Your second value is invalid: ${sideB}`)
}
else{
console.log(`Area of rectangle is: ${CalculateRectangleArea(sideA, sideB)}`);
}
//## ЗАДАЧА ##
//Если выписать все натуральные числа меньше 10, кратные 3, или 5, то получим 3, 5, 6 и 9.
//Сумма этих чисел будет равна 23.
//Напишите программу, которая выводит на экран сумму всех чисел меньше 1000, кратных 3, или 5.
//#1 натуральное число от 1 до 10 (числа которые
//#2 Натуральные числа (от лат. naturalis — «естественный») — числа, возникающие естественным образом при счёте. Примеры: 1, 2, 3, 4, 5, 6, 7 и)
//#3 Числа, кратные 3, или 5 — это числа, которые делятся на 3 или на 5 без остатка.
function SUMMA (chislo: number){
let result = 5;
console.log(`summa of numbre <1000: ${result}`);
}
/*
function DrawLine(count: number, countP: number){ //рисуем треугольник из звездочек
const minimalString = '*';
const minimalP = ' ';
let result = minimalP.repeat(countP) + minimalString.repeat(count) //с начала рисуем пробелы (countP) а потом зведочки
console.log(result);
}
function DrawTriangle(height: number, chisloP: number) { //высота - это сколько рядов отрисует
for(let index = 1; index <= height; ){
DrawLine(index * 2 - 1, chisloP - index ); // вызываем функцию DrawLine внутри цикла, chisloN - нужно иметь МАКС значение как в первом уроке
index = index +1;
//console.log(height);
}
}
rl.question('Enter something', value => {
console.log(`Hi ${value}`);
rl.close;
});
*/

View File

@ -1,19 +0,0 @@
import readline from 'node:readline';
export function ConsoleInput(text: string): string {
let result: string = '';
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
rl.question('Enter something:', value => {
result = value;
rl.close;
});
return result;
}

View File

@ -21,7 +21,6 @@
"strict": true, /* Enable all strict type-checking options. */ "strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
/* Completeness */ /* Completeness */
"skipLibCheck": true, /* Skip type checking all .d.ts files. */ "skipLibCheck": true /* Skip type checking all .d.ts files. */
"sourceMap": true
} }
} }

File diff suppressed because one or more lines are too long