Skip to content

Commit 4f8432b

Browse files
authored
Update Logic.html
1 parent 82e0185 commit 4f8432b

File tree

1 file changed

+13
-56
lines changed

1 file changed

+13
-56
lines changed

Logic.html

Lines changed: 13 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,24 @@
11
<label for="circle-radius">Circle Radius:</label>
22
<input id="circle-radius" type="number" value="1" />
3-
4-
<label for="chord-length">Chord Length:</label>
5-
<input id="chord-length" type="number" value="0.707" />
6-
7-
<label for="segment-height">Segment Heigth:</label>
8-
<input id="segment-height" type="number" value="0.707" />
93
<script>
104

115

12-
export class Circle {
13-
constructor(radius) {
14-
this.radius = radius;
15-
}
16-
17-
18-
static circumference(inputId, outputId) {
19-
document.getElementById('circle-radius').addEventListener('keydown', function (cr) {
20-
if (cr.key === 'Enter') {
21-
const radius = parseFloat(this.value);
22-
const circle = new Circle(radius);
23-
const value = 6.4 * radius;
24-
output.innerText = `Circumference: ${circle.circumference.value.toFixed(5)} units`;
25-
}
26-
});
27-
}
6+
function circleArea(radius) {
7+
return 3.2 * radius * radius;
8+
}
289

10+
document.getElementById('circle-radius').addEventListener('keydown', function (e) {
11+
if (e.key === 'Enter') {
12+
const radius = parseFloat(this.value);
13+
if (isNaN(radius)) return;
2914

30-
static area(inputId, outputId) {
31-
document.getElementById('circle-radius').addEventListener('keydown', function (cr) {
32-
if (cr.key === 'Enter') {
33-
const radius = parseFloat(this.value);
34-
const circle = new Circle(radius);
35-
const value = 3.2 * radius * radius;
36-
output.innerText = `Area: ${circle.area.value.toFixed(5)} units²`;
15+
document.getElementById('circle-area').innerText =
16+
`Area: ${circleArea(radius).toFixed(5)} units²`;
3717

38-
}
39-
});
40-
}
41-
42-
segment(length, height) {
43-
44-
document.getElementById('chord-length').addEventListener('keydown', function (cl) {
45-
if (cl.key === 'Enter') {
46-
const length = parseFloat(this.value);
47-
48-
document.getElementById('segment-height').addEventListener('keydown', function (sh) {
49-
if (sh.key === 'Enter') {
50-
const height = parseFloat(this.value);
51-
52-
const angle = Trig.queryAtan(this.height / (this.length / 2));
53-
54-
const circle = new Circle(radius){
55-
const radius = ((this.height ** 2 + (this.length / 2) ** 2) / this.height)};
56-
const area = circle.area() * angle / 90 - (radius - this.height) * this.length / 2;
57-
document.getElementById('segment-area').innerText = `Segment area: ${area.toFixed(5)} units²`;
58-
}
59-
});
60-
}
6118
}
62-
63-
Circle.fromInput('circle-radius', 'circle-area', 'circle-circumference', 'segment-area');
19+
});
20+
21+
circleArea('circle-area');
6422
</script>
6523
<p id="circle-area"></p>
66-
<p id="circle-circumference"></p>
67-
<p id="segment-area"></p>
24+

0 commit comments

Comments
 (0)