primereact

Форк
0
/
CarService.js 
38 строк · 1.0 Кб
1
export const CarService = {
2
    brands: ['Vapid', 'Carson', 'Kitano', 'Dabver', 'Ibex', 'Morello', 'Akira', 'Titan', 'Dover', 'Norma'],
3

4
    colors: ['Black', 'White', 'Red', 'Blue', 'Silver', 'Green', 'Yellow'],
5

6
    generateCar(id) {
7
        return {
8
            id,
9
            vin: this.generateVin(),
10
            brand: this.generateBrand(),
11
            color: this.generateColor(),
12
            year: this.generateYear()
13
        };
14
    },
15

16
    generateVin() {
17
        let text = '';
18
        let possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
19

20
        for (let i = 0; i < 5; i++) {
21
            text += possible.charAt(Math.floor(Math.random() * possible.length));
22
        }
23

24
        return text;
25
    },
26

27
    generateBrand() {
28
        return this.brands[Math.floor(Math.random() * Math.floor(10))];
29
    },
30

31
    generateColor() {
32
        return this.colors[Math.floor(Math.random() * Math.floor(7))];
33
    },
34

35
    generateYear() {
36
        return 2000 + Math.floor(Math.random() * Math.floor(19));
37
    }
38
};
39

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.