From 095706e38cff807ca8ae3ecb849ce0d57e4cbb8b Mon Sep 17 00:00:00 2001
From: Jihyun Lee <38481643+alisonjh@users.noreply.github.com>
Date: Sat, 15 Sep 2018 06:47:29 +0900
Subject: [PATCH 1/3] =?UTF-8?q?1=EC=B0=A8=20=EB=8B=A4=EA=B0=81=ED=98=95?=
=?UTF-8?q?=EB=84=93=EC=9D=B4=EA=B5=AC=ED=95=98=EA=B8=B0=20(#32)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* 1차 다각형넓이구하기
* 1.함수명 변경 2.숫자판별을 함수가 아닌 개별 함수내의 조건으로 재설정 3.let pi > const pi 4.return 오류 수정
---
index.html | 13 +++++++++++
step1.js | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 78 insertions(+)
create mode 100644 index.html
create mode 100644 step1.js
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..85479f4
--- /dev/null
+++ b/index.html
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+ polygon
+
+
+
+ 다각형 구하기
+
+
\ No newline at end of file
diff --git a/step1.js b/step1.js
new file mode 100644
index 0000000..baecdbc
--- /dev/null
+++ b/step1.js
@@ -0,0 +1,65 @@
+//다각형의 넓이 구하기
+
+//1. 원의 넓이 계산
+function getCircleArea (radius) {
+ let requiredInput = [radius];
+ if (requiredInput.length != arguments.length) {
+ let result = "인자 개수가 맞지 않습니다.";
+ return result;
+ }
+
+ if (isNaN(radius)) {
+ return 'error';
+ } else {
+ const pi = 3.14;
+ let result = pi * Number(radius) * Number(radius);
+ return result;
+ }
+}
+
+//2. 사각형의 넓이를 계산하는 함수
+function getRectangleArea (width,height) {
+ if ([width, height].length != arguments.length) {
+ let result = "인자 개수가 맞지 않습니다.";
+ return result;
+ }
+
+ if (isNaN(radius)) {
+ return 'error';
+ } else {
+ let result = Number(width) * Number(height);
+ return result;
+ }
+}
+
+//3.사다리꼴 넓이 계산 함수
+function getTrapezoidArea (upperLine,bottomLine,height) {
+ if ([upperLine, bottomLine, height].length != arguments.length) {
+ let result = "인자 개수가 맞지 않습니다.";
+ return result;
+ }
+
+ if (isNaN(radius)) {
+ return 'error';
+ } else {
+ let result = (Number(upperLine) + Number(bottomLine)) * Number(height) / 2;
+ return result;
+ }
+}
+
+//4.원기둥 넓이 계산 함수
+function getCylinderArea (radius,width) {
+ if ([radius, width].length != arguments.length) {
+ let result = "인자 개수가 맞지 않습니다.";
+ return result;
+ }
+
+ if (isNaN(radius)) {
+ return 'error';
+ } else {
+ const pi = 3.14;
+ let circle = pi * Number(radius) * Number(radius);
+ let result = circle * Number(width);
+ return result;
+ }
+}
From 97ff01ec162b41780b65e8b221c91082caa38e16 Mon Sep 17 00:00:00 2001
From: Head <40166539+HTMLhead@users.noreply.github.com>
Date: Sat, 15 Sep 2018 06:54:48 +0900
Subject: [PATCH 2/3] Step2 (#34)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* 다각형 넓이 (#29)
* index of polygonSize
* Full index of html and get area of circle, square, trapezoid, cylinder
* restart
* add sizeCircle function
* add function sizeSquare, add testcode
* add function sizeTrapezoid, add test code
* add function sizeSylinder, add distinguish test code, add test code
* modify by referring to feedback, add function getArea, add function printExecutionSequence
* Revise var to const, Change variable name arr -> ExecutionSequenceArray, and Revise PrintExecutionSequence function(revise forEach method to use arrow function),
* revise isNum function to use 'for' statement and add typenumberfunction for isNum function
* modifiy function sizeCircle to CalcCircleWidth and change inner contents
* Modify sizeSquare function to CalcRectWidth and change inner contents
* Modify sizeTrapezoid function to calcTrapezoidWidth function and revise inner contents
* Modify sizeSylinder functino to calcSylinderWidth function and revise inner context
* Modify getArea function to check Number of arguments
* Revise little bugs,(add return to calcSylinderWidth, change some upperCase to lowerCase
---
polygonSize.html | 16 ++++++++
polygonSize.js | 105 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 121 insertions(+)
create mode 100644 polygonSize.html
create mode 100644 polygonSize.js
diff --git a/polygonSize.html b/polygonSize.html
new file mode 100644
index 0000000..a43900b
--- /dev/null
+++ b/polygonSize.html
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+ polygon
+
+
+
+ 다각형의 넓이 구하기
+
+
+
+
\ No newline at end of file
diff --git a/polygonSize.js b/polygonSize.js
new file mode 100644
index 0000000..e7eebd6
--- /dev/null
+++ b/polygonSize.js
@@ -0,0 +1,105 @@
+//변수 const나 let으로 변경, 변수이름 개선
+const executionSequenceArray = [];
+
+//arrow함수 이용
+function printExecutionSequence() {
+ executionSequenceArray.forEach((v, i) => {
+ console.log((i + 1) + '번째 : ' + v)
+ })
+}
+
+//1. isNum함수 개선 isNum함수를 위한 isThatNum 함수만들기
+function isNum(number1, number2, number3) {
+ for (let i = 1; i <= arguments.length; i++) {
+ if (isTypeNumber(arguments[i - 1]) === false) {
+ return false
+ }
+ }
+ return true
+}
+
+function isTypeNumber(number) {
+ return toString.call(number) === '[object Number]'
+}
+
+
+//2. 인자를 구분할 때 !== 를 최대한 안쓰고 단순화시키는 걸로 개선
+//3. 계산하는 함수들의 이름과 인자들의 명칭들 모두 변경
+function calcCircleWidth(radius1, radius2) {
+ if (radius1 > radius2) {
+ console.log(radius1 + '부터' + radius2 + '까지라구요? 다시 한번 생각해주세요')
+ return;
+ }
+ if (isNum(...arguments) && arguments.length === 1) {
+ const circleWidth = radius1 * radius1 * Math.PI
+ console.log('반지름이 ' + radius1 + '인 원의넓이는' + circleWidth + '입니다.');
+ executionSequenceArray.push('circle');
+ return;
+ } else if (isNum(...arguments) && arguments.length === 2) {
+ for (let i = radius1; i <= radius2; i++) {
+ console.log('반지름이' + i + '인 원의 넓이 : ' + (i * i * Math.PI));
+ executionSequenceArray.push('circle')
+ }
+ return;
+ }
+ console.log('인자의 갯수가 맞지 않거나 숫자가 아닙니다.');
+}
+
+
+function calcRectWidth(RectLowerSide, RectHeight) {
+ if(isNum(...arguments) && arguments.length === 2) {
+ const RectWidth = RectLowerSide * RectHeight
+ console.log('밑변이' + RectLowerSide + '높이가' + RectHeight + '인 사각형의 넓이는' + RectWidth + '입니다.');
+ executionSequenceArray.push('Rect')
+ return;
+ }
+ console.log('인자의 갯수가 맞지 않거나 숫자가 아닙니다.')
+}
+
+function calcTrapezoidWidth(trapezoidLowerSide, trapezoidTopSide, trapezoidHeight) {
+ if(isNum(...arguments) && arguments.length === 3) {
+ const trapezoidWidth = (trapezoidLowerSide + trapezoidTopSide) * trapezoidHeight / 2
+ console.log('밑변이 ' + trapezoidLowerSide + '아랫변이 ' + trapezoidLowerSide + '높이가 ' + trapezoidHeight + '인 사다리꼴의 넓이는 ' + trapezoidWidth + '입니다.')
+ executionSequenceArray.push('trapezoid');
+ return;
+ }
+ console.log('인자의 갯수가 맞지 않거나 숫자가 아닙니다.')
+}
+
+function calcSylinderWidth (sylinderRadius, sylinderHeight) {
+ if(isNum(...arguments) && arguments.length === 2) {
+ const sylinderWidth = 2 * (sylinderRadius * sylinderRadius * Math.PI) + ((2 * Math.PI * sylinderRadius) * sylinderHeight)
+ console.log('반지름이 ' + sylinderRadius + '높이가 ' + sylinderHeight + '인 원기둥의 넓이는 ' + sylinderWidth + '입니다.');
+ executionSequenceArray.push('sylinder');
+ return;
+ }
+ console.log('인자의 갯수가 맞지 않거나 숫자가 아닙니다.');
+}
+
+
+//4. 함수 인자의 갯수 확인
+function getArea(polygon, num1, num2, num3) {
+ if (polygon === 'circle' && arguments.length === 3) {
+ calcCircleWidth(num1, num2)
+ return;
+ } else if (polygon === 'rect' && arguments.length === 3) {
+ calcRectWidth(num1, num2)
+ return;
+ } else if (polygon === 'trapezoid' && arguments.length === 4) {
+ calcTrapezoidWidth(num1, num2, num3)
+ return;
+ } else if (polygon === 'sylinder' && arguments.length === 3) {
+ calcSylinderWidth(num1, num2)
+ return;
+ } else if (polygon === 'circle' && arguments.length === 2) {
+ calcCircleWidth(num1)
+ return;
+ }
+ console.log('인자의 갯수가 맞지 않거나 숫자가 아닙니다.')
+}
+
+getArea('circle', 2, 3);
+getArea('rect', 2, 3);
+getArea('trapezoid', 2, 3, 4);
+getArea('sylinder', 2, 3);
+getArea('meiv', 3, '2');
\ No newline at end of file
From 0f4be6a1ce3cb811e4ba7ae8332a144be3ea6d5d Mon Sep 17 00:00:00 2001
From: nigayo
Date: Sat, 15 Sep 2018 07:30:18 +0900
Subject: [PATCH 3/3] Revert "Step2 (#34)"
This reverts commit 97ff01ec162b41780b65e8b221c91082caa38e16.
---
polygonSize.html | 16 --------
polygonSize.js | 105 -----------------------------------------------
2 files changed, 121 deletions(-)
delete mode 100644 polygonSize.html
delete mode 100644 polygonSize.js
diff --git a/polygonSize.html b/polygonSize.html
deleted file mode 100644
index a43900b..0000000
--- a/polygonSize.html
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
- polygon
-
-
-
- 다각형의 넓이 구하기
-
-
-
-
\ No newline at end of file
diff --git a/polygonSize.js b/polygonSize.js
deleted file mode 100644
index e7eebd6..0000000
--- a/polygonSize.js
+++ /dev/null
@@ -1,105 +0,0 @@
-//변수 const나 let으로 변경, 변수이름 개선
-const executionSequenceArray = [];
-
-//arrow함수 이용
-function printExecutionSequence() {
- executionSequenceArray.forEach((v, i) => {
- console.log((i + 1) + '번째 : ' + v)
- })
-}
-
-//1. isNum함수 개선 isNum함수를 위한 isThatNum 함수만들기
-function isNum(number1, number2, number3) {
- for (let i = 1; i <= arguments.length; i++) {
- if (isTypeNumber(arguments[i - 1]) === false) {
- return false
- }
- }
- return true
-}
-
-function isTypeNumber(number) {
- return toString.call(number) === '[object Number]'
-}
-
-
-//2. 인자를 구분할 때 !== 를 최대한 안쓰고 단순화시키는 걸로 개선
-//3. 계산하는 함수들의 이름과 인자들의 명칭들 모두 변경
-function calcCircleWidth(radius1, radius2) {
- if (radius1 > radius2) {
- console.log(radius1 + '부터' + radius2 + '까지라구요? 다시 한번 생각해주세요')
- return;
- }
- if (isNum(...arguments) && arguments.length === 1) {
- const circleWidth = radius1 * radius1 * Math.PI
- console.log('반지름이 ' + radius1 + '인 원의넓이는' + circleWidth + '입니다.');
- executionSequenceArray.push('circle');
- return;
- } else if (isNum(...arguments) && arguments.length === 2) {
- for (let i = radius1; i <= radius2; i++) {
- console.log('반지름이' + i + '인 원의 넓이 : ' + (i * i * Math.PI));
- executionSequenceArray.push('circle')
- }
- return;
- }
- console.log('인자의 갯수가 맞지 않거나 숫자가 아닙니다.');
-}
-
-
-function calcRectWidth(RectLowerSide, RectHeight) {
- if(isNum(...arguments) && arguments.length === 2) {
- const RectWidth = RectLowerSide * RectHeight
- console.log('밑변이' + RectLowerSide + '높이가' + RectHeight + '인 사각형의 넓이는' + RectWidth + '입니다.');
- executionSequenceArray.push('Rect')
- return;
- }
- console.log('인자의 갯수가 맞지 않거나 숫자가 아닙니다.')
-}
-
-function calcTrapezoidWidth(trapezoidLowerSide, trapezoidTopSide, trapezoidHeight) {
- if(isNum(...arguments) && arguments.length === 3) {
- const trapezoidWidth = (trapezoidLowerSide + trapezoidTopSide) * trapezoidHeight / 2
- console.log('밑변이 ' + trapezoidLowerSide + '아랫변이 ' + trapezoidLowerSide + '높이가 ' + trapezoidHeight + '인 사다리꼴의 넓이는 ' + trapezoidWidth + '입니다.')
- executionSequenceArray.push('trapezoid');
- return;
- }
- console.log('인자의 갯수가 맞지 않거나 숫자가 아닙니다.')
-}
-
-function calcSylinderWidth (sylinderRadius, sylinderHeight) {
- if(isNum(...arguments) && arguments.length === 2) {
- const sylinderWidth = 2 * (sylinderRadius * sylinderRadius * Math.PI) + ((2 * Math.PI * sylinderRadius) * sylinderHeight)
- console.log('반지름이 ' + sylinderRadius + '높이가 ' + sylinderHeight + '인 원기둥의 넓이는 ' + sylinderWidth + '입니다.');
- executionSequenceArray.push('sylinder');
- return;
- }
- console.log('인자의 갯수가 맞지 않거나 숫자가 아닙니다.');
-}
-
-
-//4. 함수 인자의 갯수 확인
-function getArea(polygon, num1, num2, num3) {
- if (polygon === 'circle' && arguments.length === 3) {
- calcCircleWidth(num1, num2)
- return;
- } else if (polygon === 'rect' && arguments.length === 3) {
- calcRectWidth(num1, num2)
- return;
- } else if (polygon === 'trapezoid' && arguments.length === 4) {
- calcTrapezoidWidth(num1, num2, num3)
- return;
- } else if (polygon === 'sylinder' && arguments.length === 3) {
- calcSylinderWidth(num1, num2)
- return;
- } else if (polygon === 'circle' && arguments.length === 2) {
- calcCircleWidth(num1)
- return;
- }
- console.log('인자의 갯수가 맞지 않거나 숫자가 아닙니다.')
-}
-
-getArea('circle', 2, 3);
-getArea('rect', 2, 3);
-getArea('trapezoid', 2, 3, 4);
-getArea('sylinder', 2, 3);
-getArea('meiv', 3, '2');
\ No newline at end of file