-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
90 lines (75 loc) · 2.77 KB
/
Copy pathMain.java
File metadata and controls
90 lines (75 loc) · 2.77 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package com.mosh;
public class Main {
// alt + enter
// new Browser + enter + alt/enter introduce local variable
// ctrl + B = jump to implementation of method
public static void main(String[] args) {
//uiControl();
//point();
//uiControl2();
interfacePractice();
}
public static void point(){
var point1 = new Point(1, 2);
var point2 = new Point(1, 2);
System.out.println(point1 == point2);
System.out.println(point1.equals(point2));
System.out.println(point1.hashCode());
System.out.println(point2.hashCode());
}
public static void interfacePractice(){
var calculator = new TaxCalculator2018(100_000);
var report = new TaxReport();
report.show(calculator);
report.show(new TaxCalculator2019());
}
public static void castingUpDown(){
//var control = new UIControl(true);
var textbox = new Textbox();
}
public static void show(UIControl control){
if(control instanceof Textbox){
var textbox = (Textbox) control;
textbox.setText("Hello World!");
}
System.out.println(control);
}
public static void uiControl(){
//var control = new UIControl(true);
//control.disable();
//System.out.println(control.isEnabled());
var textbox = new Textbox();
textbox.setText("I'm a textbox");
System.out.println("Textbox text: " + textbox.getText() + " Is enabled: " + textbox.isEnabled());
System.out.println(textbox);
var textbox2 = textbox;
System.out.println(textbox.hashCode());
System.out.println(textbox2.hashCode());
System.out.println(textbox.equals(textbox2));
}
public static void uiControl2(){
UIControl[] controls = {new Textbox(), new CheckBox()};
for (var control : controls){
control.render();
}
}
public static void mortgageCalculator(){
var principal = (int) Console.readNumber(
"Principal ($1k - $1M): ", 1000, 1_000_000);
var annualInterest = (float) Console.readNumber(
"Annual interest rate: ", 1, 30);
var periodYears = (byte) Console.readNumber(
"Period (years): ", 1, 30);
var calculator = new MortgageCalculator(principal, annualInterest, periodYears);
var report = new MortgageReport(calculator);
report.printMortgage();
report.printPaymentSchedule();
}
public static void employee(){
var employee = new Employee(50_000, 20);
employee.calculateWage(10);
var employee2 = new Employee(60_000, 20);
System.out.println(Employee.numberOfEmployees);
Employee.printNumberOfEmployees();
}
}