Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
H
homework43
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chingiz
homework43
Commits
30ed4828
Commit
30ed4828
authored
Feb 28, 2024
by
Chingiz
💻
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
task 1 has been created
parent
e072b5b3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
111 additions
and
0 deletions
+111
-0
index.js
task1/js/index.js
+49
-0
index.ts
task1/src/index.ts
+62
-0
No files found.
task1/js/index.js
0 → 100644
View file @
30ed4828
"use strict"
;
class
Figure
{
constructor
()
{
this
.
area
=
0
;
this
.
figure
=
"figure"
;
}
}
class
Rectangle
extends
Figure
{
constructor
(
height
,
lenght
)
{
super
();
this
.
figure
=
"Rectangle"
;
this
.
height
=
height
;
this
.
lenght
=
lenght
;
}
calculateArea
()
{
this
.
area
=
this
.
height
*
this
.
lenght
;
}
}
class
Triangle
extends
Figure
{
constructor
(
height
,
baseline
)
{
super
();
this
.
figure
=
"Triangle"
;
this
.
height
=
height
;
this
.
baseline
=
baseline
;
}
calculateArea
()
{
this
.
area
=
(
this
.
height
*
this
.
baseline
)
/
2
;
}
}
class
Cerlce
extends
Figure
{
constructor
(
radius
)
{
super
();
this
.
figure
=
"Cercle"
;
this
.
radius
=
radius
;
}
calculateArea
()
{
this
.
area
=
Math
.
PI
*
Math
.
sqrt
(
this
.
radius
);
}
}
const
Figures
=
[
new
Rectangle
(
20
,
30
),
new
Triangle
(
40
,
60
),
new
Cerlce
(
40
)];
const
printFigures
=
(
arr
)
=>
{
arr
.
forEach
(
figure
=>
{
figure
.
calculateArea
();
console
.
log
(
`Area of
${
figure
.
figure
}
:`
,
figure
.
area
);
});
};
printFigures
(
Figures
);
task1/src/index.ts
0 → 100644
View file @
30ed4828
abstract
class
Figure
{
public
area
:
number
=
0
;
public
figure
:
string
=
"figure"
;
public
abstract
calculateArea
():
void
;
}
class
Rectangle
extends
Figure
{
public
height
:
number
;
public
lenght
:
number
;
public
override
figure
:
string
=
"Rectangle"
;
constructor
(
height
:
number
,
lenght
:
number
){
super
();
this
.
height
=
height
;
this
.
lenght
=
lenght
;
}
public
override
calculateArea
():
void
{
this
.
area
=
this
.
height
*
this
.
lenght
;
}
}
class
Triangle
extends
Figure
{
public
height
:
number
;
public
baseline
:
number
;
public
override
figure
:
string
=
"Triangle"
;
constructor
(
height
:
number
,
baseline
:
number
){
super
();
this
.
height
=
height
;
this
.
baseline
=
baseline
;
}
public
override
calculateArea
():
void
{
this
.
area
=
(
this
.
height
*
this
.
baseline
)
/
2
;
}
}
class
Cerlce
extends
Figure
{
public
radius
:
number
;
public
override
figure
:
string
=
"Cercle"
;
constructor
(
radius
:
number
){
super
();
this
.
radius
=
radius
;
}
public
override
calculateArea
():
void
{
this
.
area
=
Math
.
PI
*
Math
.
sqrt
(
this
.
radius
);
}
}
const
Figures
=
[
new
Rectangle
(
20
,
30
),
new
Triangle
(
40
,
60
),
new
Cerlce
(
40
)]
const
printFigures
=
(
arr
:
Figure
[])
=>
{
arr
.
forEach
(
figure
=>
{
figure
.
calculateArea
();
console
.
log
(
`Area of
${
figure
.
figure
}
:`
,
figure
.
area
);
});
}
printFigures
(
Figures
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment