11const personGenerator = {
22 surnameJson : `{
3- "count": 15 ,
3+ "count": 16 ,
44 "list": {
55 "id_1": "Иванов",
66 "id_2": "Смирнов",
@@ -20,6 +20,21 @@ const personGenerator = {
2020 "id_16": "Морозов"
2121 }
2222 }` ,
23+ firstNameFemaleJson : `{
24+ "count": 10,
25+ "list": {
26+ "id_1": "Екатерина",
27+ "id_2": "Анна",
28+ "id_3": "Рита",
29+ "id_4": "Мария",
30+ "id_5": "Юлия",
31+ "id_6": "Алиса",
32+ "id_7": "Полина",
33+ "id_8": "Соня",
34+ "id_9": "Ольга",
35+ "id_10": "Елена"
36+ }
37+ }` ,
2338 firstNameMaleJson : `{
2439 "count": 10,
2540 "list": {
@@ -35,6 +50,55 @@ const personGenerator = {
3550 "id_10": "Андрей"
3651 }
3752 }` ,
53+ middleNameJson : `{
54+ "count": 10,
55+ "list": {
56+ "id_1": "Александро",
57+ "id_2": "Максимо",
58+ "id_3": "Ивано",
59+ "id_4": "Артемо",
60+ "id_5": "Дмитре",
61+ "id_6": "Никито",
62+ "id_7": "Михаило",
63+ "id_8": "Даниило",
64+ "id_9": "Егоро",
65+ "id_10": "Андрее"
66+ }
67+ }` ,
68+ monthJson : `{
69+ "count": 12,
70+ "list": {
71+ "id_1": "Января",
72+ "id_2": "Февраля",
73+ "id_3": "Марта",
74+ "id_4": "Апреля",
75+ "id_5": "Мая",
76+ "id_6": "Июня",
77+ "id_7": "Июля",
78+ "id_8": "Августа",
79+ "id_9": "Сентября",
80+ "id_10": "Октября",
81+ "id_11": "Ноября",
82+ "id_12": "Декабря"
83+ }
84+ }` ,
85+ professionJson : `{
86+ "count": 12,
87+ "list": {
88+ "id_1": "Шахтер",
89+ "id_2": "Повар",
90+ "id_3": "Врач",
91+ "id_4": "Медсестра",
92+ "id_5": "Водитель",
93+ "id_6": "Строитель",
94+ "id_7": "Официант",
95+ "id_8": "Программист",
96+ "id_9": "Инженер",
97+ "id_10": "Солдат",
98+ "id_11": "Менеджер",
99+ "id_12": "Риэлтор"
100+ }
101+ }` ,
38102
39103 GENDER_MALE : 'Мужчина' ,
40104 GENDER_FEMALE : 'Женщина' ,
@@ -53,18 +117,78 @@ const personGenerator = {
53117
54118 } ,
55119
120+ randomFirstNameShe : function ( ) {
121+
122+ return this . randomValue ( this . firstNameFemaleJson ) ;
123+
124+ } ,
56125
57- randomSurname : function ( ) {
126+ randomSurname : function ( ) {
58127
59128 return this . randomValue ( this . surnameJson ) ;
60129
61130 } ,
62131
132+ randomMiddleName : function ( ) {
133+
134+ return this . randomValue ( this . middleNameJson ) ;
135+
136+ } ,
137+
138+ randomMonth : function ( ) {
139+
140+ return this . randomValue ( this . monthJson ) ;
141+
142+ } ,
143+
144+ randomProfession : function ( ) {
145+
146+ return this . randomValue ( this . professionJson ) ;
147+
148+ } ,
149+
150+ randomGender : function ( ) {
151+ const randomGender = this . randomIntNumber ( 2 , 1 ) ;
152+ if ( randomGender == 1 ) {
153+ return this . GENDER_MALE ;
154+ } else {
155+ return this . GENDER_FEMALE ;
156+ }
157+ } ,
63158
64159 getPerson : function ( ) {
65160 this . person = { } ;
66- // this.person.gender = this.randomGender();
67- this . person . firstName = this . randomFirstName ( ) ;
161+ this . person . year = this . randomIntNumber ( 2002 , 1920 ) ;
162+ const crazyYear = this . person . year % 4 ;
163+ this . person . month = this . randomMonth ( ) ;
164+ if ( ( this . person . month == "Апреля" ) || ( this . person . month == "Июня" ) || ( this . person . month == "Сентября" ) || ( this . person . month == "Ноября" ) ) {
165+ this . person . day = this . randomIntNumber ( 30 , 1 ) ;
166+ } else if ( this . person . month == "Февраля" ) {
167+ if ( crazyYear == 0 ) {
168+ this . person . day = this . randomIntNumber ( 29 , 1 ) ;
169+ } else {
170+ this . person . day = this . randomIntNumber ( 28 , 1 ) ; } ;
171+ } else {
172+ this . person . day = this . randomIntNumber ( 30 , 1 ) ; } ;
173+ this . person . profession = this . randomProfession ( ) ;
174+ if ( this . person . profession == "Медсестра" ) {
175+ this . person . gender = this . GENDER_FEMALE ;
176+ } else if ( ( this . person . profession == "Шахтер" ) || ( this . person . profession == "Строитель" ) || ( this . person . profession == "Солдат" ) ) {
177+ this . person . gender = this . GENDER_MALE ;
178+ } else {
179+ this . person . gender = this . randomGender ( ) ;
180+ } ;
181+ if ( this . person . gender == this . GENDER_MALE ) {
182+ this . person . firstName = this . randomFirstName ( ) ;
183+ this . person . surname = this . randomSurname ( ) ;
184+ this . person . middleName = `${ this . randomMiddleName ( ) } вич` ;
185+ } else {
186+ this . person . firstName = this . randomFirstNameShe ( ) ;
187+ this . person . surname = `${ this . randomSurname ( ) } a` ;
188+ this . person . middleName = `${ this . randomMiddleName ( ) } вна` ;
189+ }
190+
68191 return this . person ;
69- }
192+ } ,
193+
70194} ;
0 commit comments