Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5791b9e

Browse files
committed
Added Entity folder in the MVCPracticeAdvanced section of a small course on Java EE
1 parent 76fe8e1 commit 5791b9e

File tree

6 files changed

+307
-0
lines changed

6 files changed

+307
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package AirportSimulatorTwo.Entity.EntityEnum;
2+
3+
public enum FlightStatus {
4+
ARRIVED,
5+
DEPARTED,
6+
CANCELLED,
7+
SCHEDULED
8+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package AirportSimulatorTwo.Entity.EntityEnum;
2+
3+
import java.util.Arrays;
4+
import java.util.Optional;
5+
6+
public enum Gender {
7+
MALE,
8+
FEMALE;
9+
10+
public static Optional<Gender> find(String gender) {
11+
return Arrays.stream(values()).
12+
filter(it -> it.name().equals(gender)).
13+
findFirst();
14+
}
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package AirportSimulatorTwo.Entity.EntityEnum;
2+
3+
import java.util.Arrays;
4+
import java.util.Optional;
5+
6+
public enum Role {
7+
USER,
8+
ADMIN;
9+
10+
public static Optional<Role> find(String role) {
11+
return Arrays.stream(values()).
12+
filter(it -> it.name().equals(role)).
13+
findFirst();
14+
}
15+
}
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
package AirportSimulatorTwo.Entity;
2+
3+
import AirportSimulatorTwo.Entity.EntityEnum.FlightStatus;
4+
5+
import java.time.LocalDateTime;
6+
import java.util.Objects;
7+
8+
public class Flight {
9+
private Long id;
10+
private String flight_no;
11+
private LocalDateTime departure_date;
12+
private String departure_airport_code;
13+
private LocalDateTime arrival_date;
14+
private String arrival_airport_code;
15+
private Integer aircraft_id;
16+
private FlightStatus status;
17+
18+
public Flight() {
19+
}
20+
21+
public Flight(Long id, String flight_no, LocalDateTime departure_date,
22+
String departure_airport_code, LocalDateTime arrival_date,
23+
String arrival_airport_code, Integer aircraft_id,
24+
FlightStatus status) {
25+
this.id = id;
26+
this.flight_no = flight_no;
27+
this.departure_date = departure_date;
28+
this.departure_airport_code = departure_airport_code;
29+
this.arrival_date = arrival_date;
30+
this.arrival_airport_code = arrival_airport_code;
31+
this.aircraft_id = aircraft_id;
32+
this.status = status;
33+
}
34+
35+
public Long getId() {
36+
return id;
37+
}
38+
39+
public void setId(Long id) {
40+
this.id = id;
41+
}
42+
43+
public String getFlight_no() {
44+
return flight_no;
45+
}
46+
47+
public void setFlight_no(String flight_no) {
48+
this.flight_no = flight_no;
49+
}
50+
51+
public LocalDateTime getDeparture_date() {
52+
return departure_date;
53+
}
54+
55+
public void setDeparture_date(LocalDateTime departure_date) {
56+
this.departure_date = departure_date;
57+
}
58+
59+
public String getDeparture_airport_code() {
60+
return departure_airport_code;
61+
}
62+
63+
public void setDeparture_airport_code(String departure_airport_code) {
64+
this.departure_airport_code = departure_airport_code;
65+
}
66+
67+
public LocalDateTime getArrival_date() {
68+
return arrival_date;
69+
}
70+
71+
public void setArrival_date(LocalDateTime arrival_date) {
72+
this.arrival_date = arrival_date;
73+
}
74+
75+
public String getArrival_airport_code() {
76+
return arrival_airport_code;
77+
}
78+
79+
public void setArrival_airport_code(String arrival_airport_code) {
80+
this.arrival_airport_code = arrival_airport_code;
81+
}
82+
83+
public Integer getAircraft_id() {
84+
return aircraft_id;
85+
}
86+
87+
public void setAircraft_id(Integer aircraft_id) {
88+
this.aircraft_id = aircraft_id;
89+
}
90+
public FlightStatus getStatus() {
91+
return status;
92+
}
93+
94+
public void setStatus(FlightStatus status) {
95+
this.status = status;
96+
}
97+
98+
@Override
99+
public boolean equals(Object o) {
100+
if (this == o) return true;
101+
if (o == null || getClass() != o.getClass()) return false;
102+
Flight flight = (Flight) o;
103+
return Objects.equals(id, flight.id) &&
104+
Objects.equals(flight_no, flight.flight_no) &&
105+
Objects.equals(departure_date, flight.departure_date) &&
106+
Objects.equals(departure_airport_code, flight.departure_airport_code) &&
107+
Objects.equals(arrival_date, flight.arrival_date) &&
108+
Objects.equals(arrival_airport_code, flight.arrival_airport_code) &&
109+
Objects.equals(aircraft_id, flight.aircraft_id) &&
110+
status == flight.status;
111+
}
112+
113+
@Override
114+
public int hashCode() {
115+
return Objects.hash(id,
116+
flight_no,
117+
departure_date,
118+
departure_airport_code,
119+
arrival_date,
120+
arrival_airport_code,
121+
aircraft_id,
122+
status);
123+
}
124+
125+
@Override
126+
public String toString() {
127+
return "Flight{" +
128+
"id=" + id +
129+
", flight_no='" + flight_no + '\'' +
130+
", departure_date=" + departure_date +
131+
", departure_airport_code='" + departure_airport_code + '\'' +
132+
", arrival_date=" + arrival_date +
133+
", arrival_airport_code='" + arrival_airport_code + '\'' +
134+
", aircraft_id=" + aircraft_id +
135+
", status=" + status +
136+
'}';
137+
}
138+
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
package AirportSimulatorTwo.Entity;
2+
3+
import java.math.BigDecimal;
4+
import java.util.Objects;
5+
6+
public class Ticket {
7+
private Long id;
8+
private String passenger_no;
9+
private String passenger_name;
10+
private Long flight_id;
11+
private String seat_no;
12+
private BigDecimal cost;
13+
14+
public Ticket() {
15+
}
16+
17+
public Ticket(Long id, String passenger_no, String passenger_name,
18+
Long flight_id, String seat_no, BigDecimal cost) {
19+
this.id = id;
20+
this.passenger_no = passenger_no;
21+
this.passenger_name = passenger_name;
22+
this.flight_id = flight_id;
23+
this.seat_no = seat_no;
24+
this.cost = cost;
25+
}
26+
27+
public Long getId() {
28+
return id;
29+
}
30+
31+
public void setId(Long id) {
32+
this.id = id;
33+
}
34+
35+
public String getPassenger_no() {
36+
return passenger_no;
37+
}
38+
39+
public void setPassenger_no(String passenger_no) {
40+
this.passenger_no = passenger_no;
41+
}
42+
43+
public String getPassenger_name() {
44+
return passenger_name;
45+
}
46+
47+
public void setPassenger_name(String passenger_name) {
48+
this.passenger_name = passenger_name;
49+
}
50+
51+
public Long getFlight_id() {
52+
return flight_id;
53+
}
54+
55+
public void setFlight_id(Long flight_id) {
56+
this.flight_id = flight_id;
57+
}
58+
59+
public String getSeat_no() {
60+
return seat_no;
61+
}
62+
63+
public void setSeat_no(String seat_no) {
64+
this.seat_no = seat_no;
65+
}
66+
67+
public BigDecimal getCost() {
68+
return cost;
69+
}
70+
71+
public void setCost(BigDecimal cost) {
72+
this.cost = cost;
73+
}
74+
75+
@Override
76+
public boolean equals(Object o) {
77+
if (this == o) return true;
78+
if (o == null || getClass() != o.getClass()) return false;
79+
Ticket ticket = (Ticket) o;
80+
return Objects.equals(id, ticket.id) &&
81+
Objects.equals(passenger_no, ticket.passenger_no) &&
82+
Objects.equals(passenger_name, ticket.passenger_name) &&
83+
Objects.equals(flight_id, ticket.flight_id) &&
84+
Objects.equals(seat_no, ticket.seat_no) &&
85+
Objects.equals(cost, ticket.cost);
86+
}
87+
88+
@Override
89+
public int hashCode() {
90+
return Objects.hash(id, passenger_no, passenger_name,
91+
flight_id, seat_no, cost);
92+
}
93+
94+
@Override
95+
public String toString() {
96+
return "Ticket{" +
97+
"id=" + id +
98+
", passenger_no='" + passenger_no + '\'' +
99+
", passenger_name='" + passenger_name + '\'' +
100+
", flight_id=" + flight_id +
101+
", seat_no='" + seat_no + '\'' +
102+
", cost=" + cost +
103+
'}';
104+
}
105+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package AirportSimulatorTwo.Entity;
2+
3+
import AirportSimulatorTwo.Entity.EntityEnum.Gender;
4+
import AirportSimulatorTwo.Entity.EntityEnum.Role;
5+
import lombok.AllArgsConstructor;
6+
import lombok.Builder;
7+
import lombok.Data;
8+
import lombok.NoArgsConstructor;
9+
10+
import java.time.LocalDate;
11+
12+
/* Сокращаем написание кода используя Lombok */
13+
@Data
14+
@NoArgsConstructor
15+
@AllArgsConstructor
16+
@Builder
17+
public class User {
18+
private Integer id;
19+
private String name;
20+
private LocalDate birthday;
21+
private String email;
22+
private String image; // Храним путь к нашей картинке, путь пропишем в файле свойств
23+
private String password;
24+
private Role role; // Используем ENUM
25+
private Gender gender; // Используем ENUM
26+
}

0 commit comments

Comments
 (0)