-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
39 lines (30 loc) · 1.08 KB
/
Copy pathMain.java
File metadata and controls
39 lines (30 loc) · 1.08 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
import java.lang.String;
class Products {
public int code;
public double price;
public String name;
//constructor με αντικείμενα
public Products(int code, double price, String name) {
this.code = code;
this.name = name;
this.price = price;
}
//Οι συναρτήσεις επιστρέφουν τις τιμές των αντικειμένων
public int getcode() {
return code;
}
public double getprice() {
return price;
}
public String getstring() {return name; }
public String toString() {
return "Κωδικός : " + this.code + ", Όνομα : " + this.name + ",\t\t Τιμή : " + this.price+"€";
}
}
public class Main {
public static void main(String[] args) {
//Δημιουργία νέου αντικειμένου προκειμένου να αποδώσει τις τιμές στις συναρτήσεις της κλάσης
CashRegister register = new CashRegister();
register.create();
}
}