File tree 1 file changed +50
-0
lines changed
1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < meta charset ="UTF-8 ">
5
+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge ">
6
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
7
+ < title > Document</ title >
8
+ </ head >
9
+ < body >
10
+ < form id ="kockaForma ">
11
+ < label for ="duzinaStranice "> Dužina stranice:</ label >
12
+ < input type ="number " id ="duzinaStranice " name ="duzinaStranice " required >
13
+ < button type ="submit "> Kreiraj kocku</ button >
14
+ </ form >
15
+
16
+ < div id ="rezultati "> </ div >
17
+ </ body >
18
+ </ html >
19
+ < script >
20
+ class Kocka {
21
+ constructor ( a ) {
22
+ this . a = a ;
23
+ }
24
+
25
+ izracunajZapreminu ( ) {
26
+ return this . a * this . a * this . a ;
27
+ }
28
+
29
+ izracunajUkupnuDuzinuStranica ( ) {
30
+ return 12 * this . a ;
31
+ }
32
+ }
33
+
34
+ document . getElementById ( "kockaForma" ) . addEventListener ( "submit" , function ( event ) {
35
+ event . preventDefault ( ) ;
36
+
37
+ // Dobijanje unesene dužine stranice
38
+ let duzinaStranice = parseFloat ( document . getElementById ( "duzinaStranice" ) . value ) ;
39
+
40
+ // Kreiranje objekta kocke
41
+ let kocka = new Kocka ( duzinaStranice ) ;
42
+
43
+ // Prikaz rezultata
44
+ let rezultatiDiv = document . getElementById ( "rezultati" ) ;
45
+ rezultatiDiv . innerHTML = "" ;
46
+ rezultatiDiv . innerHTML += "Zapremina kocke: " + kocka . izracunajZapreminu ( ) + "<br>" ;
47
+ rezultatiDiv . innerHTML += "Ukupna dužina stranica kocke: " + kocka . izracunajUkupnuDuzinuStranica ( ) + "<br>" ;
48
+ } ) ;
49
+
50
+ </ script >
You can’t perform that action at this time.
0 commit comments