@@ -35,6 +35,21 @@ const personGenerator = {
35
35
"id_10": "Андрей"
36
36
}
37
37
}` ,
38
+ firstNameFemaleJson : `{
39
+ "count": 10,
40
+ "list": {
41
+ "id_1": "Анастасия",
42
+ "id_2": "София",
43
+ "id_3": "Дарья",
44
+ "id_4": "Мария",
45
+ "id_5": "Александра",
46
+ "id_6": "Алиса",
47
+ "id_7": "Елизавета",
48
+ "id_8": "Полина",
49
+ "id_9": "Варвара",
50
+ "id_10": "Екатерина"
51
+ }
52
+ }` ,
38
53
39
54
GENDER_MALE : 'Мужчина' ,
40
55
GENDER_FEMALE : 'Женщина' ,
@@ -49,22 +64,72 @@ const personGenerator = {
49
64
50
65
randomFirstName : function ( ) {
51
66
52
- return this . randomValue ( this . firstNameMaleJson ) ;
67
+ if ( this . person . gender === this . GENDER_MALE )
68
+ {
69
+ return this . randomValue ( this . firstNameMaleJson ) ;
70
+ }
71
+ else
72
+ {
73
+ return this . randomValue ( this . firstNameFemaleJson ) ;
74
+ }
75
+
76
+ } ,
77
+
78
+
79
+ randomSurname : function ( ) {
80
+
81
+ let result = this . randomValue ( this . surnameJson ) ;
82
+
83
+ if ( this . person . gender === this . GENDER_FEMALE )
84
+ {
85
+ result = result + "а" ;
86
+ }
87
+
88
+ return result ;
89
+
90
+ } ,
91
+
92
+ randomGender : function ( ) {
93
+
94
+ return this . randomIntNumber ( ) === 1 ? this . GENDER_MALE : this . GENDER_FEMALE ;
53
95
54
96
} ,
55
97
98
+ randomDate : function ( ) {
56
99
57
- randomSurname : function ( ) {
100
+ const year = this . randomIntNumber ( 110 , 70 ) + 1900 ;
101
+ const month = this . randomIntNumber ( 12 , 1 ) ;
102
+
103
+ const isEven = month % 2 === 0 ;
104
+
105
+ let maxDay ;
106
+
107
+ if ( month === 2 )
108
+ {
109
+ const isLeap = year % 4 === 0 ;
110
+ maxDay = isLeap ? 29 : 28 ;
111
+ }
112
+ else if ( month < 8 )
113
+ {
114
+ maxDay = isEven ? 30 : 31 ;
115
+ }
116
+ else
117
+ {
118
+ maxDay = isEven ? 31 : 30 ;
119
+ }
58
120
59
- return this . randomValue ( this . surnameJson ) ;
121
+ const day = this . randomIntNumber ( maxDay , 1 ) ;
60
122
123
+ return `${ day } .${ month } .${ year } ` ;
61
124
} ,
62
125
63
126
64
127
getPerson : function ( ) {
65
128
this . person = { } ;
66
- // this.person.gender = this.randomGender();
129
+ this . person . gender = this . randomGender ( ) ;
67
130
this . person . firstName = this . randomFirstName ( ) ;
131
+ this . person . surName = this . randomSurname ( ) ;
132
+ this . person . birthday = this . randomDate ( ) ;
68
133
return this . person ;
69
134
}
70
135
} ;
0 commit comments