-
Notifications
You must be signed in to change notification settings - Fork 37
다각형 넓이 #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
다각형 넓이 #29
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3e7f64e
index of polygonSize
HTMLhead b3d7353
Full index of html and get area of circle, square, trapezoid, cylinder
HTMLhead a7c4036
restart
HTMLhead 176f5a0
add sizeCircle function
HTMLhead c7ce1b8
add function sizeSquare, add testcode
HTMLhead a11e2e1
add function sizeTrapezoid, add test code
HTMLhead 0891c18
add function sizeSylinder, add distinguish test code, add test code
HTMLhead File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,16 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
|
|
||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
| <title>polygon</title> | ||
| </head> | ||
|
|
||
| <body> | ||
| <h2>다각형의 넓이 구하기</h2> | ||
| <script src = 'polygonSize.js'></script> | ||
| </body> | ||
|
|
||
| </html> |
This file contains hidden or 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,67 @@ | ||
| function sizeCircle(radius) { | ||
| if (toString.call(radius) != '[object Number]') { | ||
| return console.log('숫자만 계산 가능합니다.'); | ||
| } | ||
| const circleArea = radius * radius * Math.PI | ||
| console.log('반지름이 ' + radius + '인 원의넓이는' + circleArea + '입니다.'); | ||
| } | ||
| //test circle | ||
| console.log('원') | ||
| sizeCircle(4) | ||
| sizeCircle('문자') | ||
| sizeCircle(); | ||
|
|
||
| function sizeSquare(lowerSide, height) { | ||
| if (lowerSide === undefined || height === undefined) { | ||
| return console.log('인자가 부족합니다.') | ||
| } else if (toString.call(lowerSide) != '[object Number]' || toString.call(height) != '[object Number]') { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. else if(여기) |
||
| return console.log('숫자만 계산 가능합니다.') | ||
| } | ||
| const squareArea = lowerSide * height | ||
| console.log('밑변과 높이가 ' + lowerSide + ', ' + height + '인 사각형의 넓이는' + squareArea + '입니다.') | ||
| } | ||
|
|
||
| //test square | ||
| console.log('사각형') | ||
| sizeSquare(4, 3) | ||
| sizeSquare(3) | ||
| sizeSquare() | ||
| sizeSquare('문자', '문자'); | ||
| sizeSquare('문자'); | ||
|
|
||
| function sizeTrapezoid(topSide, lowerSide, height) { | ||
| if (topSide === undefined || lowerSide === undefined || height === undefined) { | ||
| return console.log('인자가 부족합니다.') | ||
| } else if (toString.call(topSide) != '[object Number]' || toString.call(lowerSide) != '[object Number]' || toString.call(height) != '[object Number]') { | ||
| return console.log('숫자만 계산할 수 있습니다.') | ||
| } | ||
| const trapezoidArea = (topSide + lowerSide) * height / 2 | ||
| console.log('윗변과 아랫변과 높이가 ' + topSide + ', ' + lowerSide + ', ' + height + '인 사다리꼴의 넓이는' + trapezoidArea + '입니다.') | ||
| } | ||
|
|
||
| //test trapezoid | ||
| console.log('사다리꼴') | ||
| sizeTrapezoid(2, 3, 4) | ||
| sizeTrapezoid(2, 3) | ||
| sizeTrapezoid('문자', 2, 3) | ||
| sizeTrapezoid('문자', '문자', '문자') | ||
| sizeTrapezoid() | ||
|
|
||
| function sizeSylinder(radius, height) { | ||
| if (radius === undefined || height === undefined) { | ||
| return console.log('인자가 부족합니다.') | ||
| } else if (toString.call(radius) != '[object Number]' || toString.call(height) != '[object Number]') { | ||
| return console.log('숫자만 계산할 수 있습니다.') | ||
| } | ||
| const sylinderArea = (Math.PI * radius * radius) + ((2 * radius * Math.PI) * height) | ||
| console.log('반지름과 높이가' + radius + ', ' + height + '인 원기둥의 겉넓이는 ' + sylinderArea + '입니다.') | ||
| } | ||
|
|
||
| //test sizeSylinder | ||
| console.log('원기둥') | ||
| sizeSylinder(2, 3) | ||
| sizeSylinder(2) | ||
| sizeSylinder('문자') | ||
| sizeSylinder('문자', 3) | ||
| sizeSylinder() | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
인자의 갯수를 확인하는 것이면,
arguments 갯수를 확인할 수도 있겠네요.