1fn get_aerith() -> PlayerCharacter {
2 return PlayerCharacter::new(
3 "Aerith",
4 "Gainsborough",
5 "Great Gospel",
6 "Princess Guard",
7 EyeColor::Green,
8 163,
9 );
10}
11
12fn get_tifa() -> PlayerCharacter {
13 return PlayerCharacter::new(
14 "Tifa",
15 "Lockheart",
16 "Final Heaven",
17 "Premium Heart",
18 EyeColor::Red,
19 167,
20 );
21}
22
23fn get_cloud() -> PlayerCharacter {
24 return PlayerCharacter::new(
25 "Cloud",
26 "Strife",
27 "Omnislash",
28 "Ultima Weapon",
29 EyeColor::Blue,
30 173,
31 );
32}
33
34pub fn about_aerith() {
35 let char_aerith = get_aerith();
36 println!(" First Name: {}
37 Last Name: {}
38Ultimate Limit Break: {}
39 Ultimate Weapon: {}
40 Eye Color: {:?}
41 Height: {}cm
42 ",
43 char_aerith.first_name,
44 char_aerith.last_name,
45 char_aerith.ultimate_limit_break,
46 char_aerith.ultimate_weapon,
47 char_aerith.eye_color.unwrap().as_str(),
48 char_aerith.height,
49 );
50}
51
52impl EyeColor {
53 fn as_str(&self) -> &str {
54 match self {
55 EyeColor::Green => "Green",
56 EyeColor::Blue => "Blue",
57 EyeColor::Brown => "Brown",
58 EyeColor::Red => "Red",
59 _ => "Unknown"
60 }
61 }
62}
63
64enum EyeColor {
65 Green,
66 Blue,
67 Brown,
68 Red,
69}
70
71struct PlayerCharacter {
72 first_name: String,
73 last_name: String,
74 ultimate_limit_break: String,
75 ultimate_weapon: String,
76 eye_color: Option<EyeColor>,
77 height: u16, }
79
80impl PlayerCharacter {
81 fn new(
82 first_name: &str,
83 last_name: &str,
84 ultimate_limit_break: &str,
85 ultimate_weapon: &str,
86 eye_color: EyeColor,
87 height: u16,
88 ) -> PlayerCharacter {
89 return PlayerCharacter{
90 first_name: first_name.to_string(),
91 last_name: last_name.to_string(),
92 ultimate_limit_break: ultimate_limit_break.to_string(),
93 ultimate_weapon: ultimate_weapon.to_string(),
94 eye_color: Some(eye_color),
95 height: height,
96 }
97 }
98}