ASK     CORE     EXT     CODE     CODE    

---------------------------------------------------------------------------

        //     1.   Проверка имени пользователя на валидность         //     quizful.net    
        //     2.   Найти длину самой длинной последовательности повторяющихся чисел в списке
        //     3.   Генератор кода
        //     4.   YouTube

---------------------------------------------------------------------------

        //     2.   Найти длину самой длинной последовательности повторяющихся чисел в списке         //     github.com

Пример :   для списка :   2, 4, 4, 4, 8, 8, 9, 12, 12, 14   -->   Ответ = 3   ( 4, 4, 4 )


int count = 1;
int max = 1;

for (int i=0; i<list.size()-1; i++) {

        if (list.get(i) == list.get(i + 1)) {
                count++;
                if (max < count) {
                        max = count;
                }
        }
        else {
                count=1;
        }
}

---------------------------------------------------------------------------

        //     3.   Генератор кода


package quicc.main.utilz;

import queen.model.backlite.*;

public class CodeGen {

        public static void main(String... args) {

                Production data = new Production();

                System.out.println(" public List<ExcelStats> getDiff(Production newData) {\n" +
                        "         List<ExcelStats> diffs = new ArrayList<>();");

                QuiccUtils.getDiffCode(data, "backlite");

                System.out.println("return diffs;\n" +
                        "         }");

        }

}



package quicc.main.utilz;

import org.springframework.util.ClassUtils;
import quicc.model.main.statistics.ExcelStats;

import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Field;
import java.util.*;

public enum QuiccUtils {

INSTANCE;

        public static void getDiffCode(Object data, String quicc) {

                Field[] fields = data.getClass().getDeclaredFields();
                AccessibleObject.setAccessible(fields, true);

                for (Field f : fields) {
               
                        try {
                                if (ClassUtils.isPrimitiveOrWrapper(f.getType()) || f.getType().equals(String.class)) {
                                        String fname = f.getName();
                                        String getter = "get" + fname.substring(0, 1).toUpperCase() + fname.substring(1) + "()";
                                        System.out.println("if (this." + fname + " != null && !this." + fname + ".equals(newData." + getter + ")) {\n" +
                                        "                 diffs.add(new ExcelStats(\"" + quicc + "\", \"XXXXXXXXXXXXXXXXXXXXXX\", this." + getter + ", newData." + getter + ", \"DOUBLE\", new Date()));\n" +
                                        "         }");
                                        // System.out.println("this." + fname + " != null && ");
                                }
                                else {
                                        if (!f.getType().equals(List.class) && !f.getType().equals(Map.class))
                                        getDiffCode(f.get(data), quicc);
                                }
                        }

                        catch (IllegalAccessException e) {
                                e.printStackTrace();
                        }

                }

        }

}

---------------------------------------------------------------------------

        //     4.   YouTube

import java.io.IOException;
import java.awt.Desktop;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Random;

public class Main {

        public static void main(String[] args) {

                String m0 = "https://www.youtube.com/watch?time_continue=2&v=NBJx_CSt75o";
                String m1 = "https://www.youtube.com/watch?v=djV11Xbc914";
                String m2 = "https://www.youtube.com/watch?v=Z4b1PMmTEb8";

                ArrayList<String> list = new ArrayList<String>();
                list.add(m0);
                list.add(m1);
                list.add(m2);

                while (true) {
                        int nextSong = rand();
                        if (Desktop.isDesktopSupported()) {
                                try {
                                        Desktop.getDesktop().browse(new URI(list.get(nextSong)));
                                }
                                catch (IOException e) {
                                        e.printStackTrace();
                                }
                                catch (URISyntaxException e) {
                                        e.printStackTrace();
                                }
                                try {
                                        Thread.currentThread().sleep(200000);
                                }
                                catch (InterruptedException e) {
                                        e.printStackTrace();
                                }
                        }
                }

        }

public static int rand() {
                Random random = new Random();
                int x = random.nextInt(2);
                return x;
        }

}