-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrecords.html
44 lines (37 loc) · 1.17 KB
/
records.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://javaalmanac.io/almanac.min.css">
</head>
<body>
<h1>3.1 Εισαγωγή στον Αντικειμενοστραφή Προγραμματισμό</h1>
<h3>© Γιάννης Κωστάρας</h3>
<div class="content" id="content">
<sandbox version="java17" mainclass="Records" preview="true" v-cloak>
<sandbox-source name="Records.java">
public class Records {
public static void main(String[] args) {
record Point(int x, int y) { };
Point p = new Point (0, 0);
System.out.println(p);
record Line(Point p1, Point p2) {};
Line line = new Line(p, new Point(10, 10));
System.out.println(line);
record Rectangle(Point upperLeft, Point lowerRight) {};
record Circle(Point center, int radius) {
double circumference() {
return 2*Math.PI*radius;
}
};
Circle circle = new Circle(p, 5);
System.out.println(circle.circumference());
}
}</sandbox-source>
</sandbox>
</div>
<script src="https://javaalmanac.io/app/sandbox-bundle.js"></script>
<script>new Vue({ el: '#content' })</script>
<hr>
<a href="..">Πίσω</a>
</body>
</html>