-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjstest2.html
More file actions
69 lines (35 loc) · 1.3 KB
/
jstest2.html
File metadata and controls
69 lines (35 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<html>
<head>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
</head>
<body>
<input id="input"/>
<div id="output"></div>
<button id="button">UPDATE</button>
</body>
<script>
function ship(ship_name,gross_weight,is_submarine){
var name = ship_name;
var weight = gross_weight;
var submarine = is_submarine;
var load = function(mass){
this.weight = this.weight + mass;
}
var unload = function(mass){
this.weight = this.weight - mass;
}
}
var emperor = new ship("agamemnon",1200000,false);
var das_boot = new ship("red-october",30000,true);
$("#output").append("<p>Ship + " + emperor.name + " has weight " + emperor.weight + "</p>");
$("#output").append("<p>Ship + " + das_boot.name + " has weight " + das_boot.weight + "</p>");
emperor.load(550000);
das_boot.load(100000);
$("#output").append("<p>Ship + " + emperor.name + " has weight " + emperor.weight + "</p>");
$("#output").append("<p>Ship + " + das_boot.name + " has weight " + das_boot.weight + "</p>");
emperor.unload(50000);
das_boot.unload(30000);
$("#output").append("<p>Ship + " + emperor.name + " has weight " + emperor.weight + "</p>");
$("#output").append("<p>Ship + " + das_boot.name + " has weight " + das_boot.weight + "</p>");
</script>
</html>