<commit_before>/*
 * 
 * Autory :   <NAME>
 * 			  <NAME>
 * 			  <NAME>
 * 			  <NAME>�
 * 
 */

import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        System.out.println("Vitajte v aplikácii ");
        menu();

    }
    // hlavne menu aplikacie
    public static void menu()
    {
        while (true)
        {
            Scanner kb = new Scanner(System.in);

            System.out.println("Funkcie:");
            System.out.println("    1 Prevod medzi sústavami");
            System.out.println("    2 Maska/Prefix");
            System.out.println("    3 IP Review");
            System.out.print("Vyberte funkciu: ");
            int y;
            try {
                y = kb.nextInt();    // vyber funkcii
            }
            catch (Exception e)
            {
                System.out.println("Zlý vstup.");
                System.out.println();
                System.out.println();
                continue;
            }
            System.out.println();
            switch (y)
            {
                case 1:
                    convertUI(true, 0, 0);
                    break;
                case 2:
                    prefixUI(true, 0, 0);
                    break;
                case 3:
                    System.out.println("    3 IP Review");
                    break;
                default:
                    System.out.println("Zadaj číslo fukcie");
                    menu();
                    break;
            }
        }
    }
    // metoda ktorá roby 1.prevod medzy sústavami
    public static void convertUI(boolean que, int y, int u)		// gue: true-od zaciatku,false-predosli prevod y,u= predosli prevod
    {
        while(true)
        {
            Scanner kb2 = new Scanner(System.in);
            if (que)
            {
                System.out.println("Z ktorej sústavy chceš prevádzať:");
                System.out.println("    1 Binarna");
                System.out.println("    2 Decimálna");
                y = kb2.nextInt();                    // vyber moznosti
                System.out.println("Do ktorej sústavy chceš prevádzať:");	// zobrazovat sa bude ponuka bez moznosti ktora bola uz vybrana
                u = 0;
                if(y == 2)	
                {
                    System.out.println("    1 Binarna");
                    u = kb2.nextInt();				// vyber moznosti
                    u = 1;
                }
                if(y == 1)
                {
                    System.out.println("    1 Decimálna");
                    u = kb2.nextInt();				// vyber moznosti
                    u = 2;
                }
                System.out.println();
            }

            switch (y)
            {
                case 1:
                    if(u == 2)
                    {
                        System.out.print("Zadaj binarne číslo: ");
                        int[] in = getBinNum();
                        System.out.println("Zadané číslo v desiatkovej sústave je: " + fromBinToDec(in));
                    }
                    break;
                case 2:
                    if(u == 1)
                    {
                        System.out.print("Zadaj decimalne číslo: ");
                        int in = kb2.nextInt();
                        System.out.print("Zadané číslo v binárnej sústave je: ");
                        for (int x : fromDecToBin(in))
                        {
                            System.out.print(x);
                        }
                    }

                    break;
                default:
                    System.out.println("Zlý vstup");
                    convertUI(true, 0, 0);
            }
            kb2.nextLine();

            System.out.println();
            System.out.println();

            System.out.println("Čo chceš robiť? Pokračovať s nastaveným prevodom = Enter  Nový prevod = 0  Menu = 1");
            String back = kb2.nextLine();
            try {
                int in = Integer.parseInt(back);
                if(in == 0)
                {
                   convertUI(true, 0, 0);		// metoda sa zacne vykonavat od zaciatku
                }
                if (in == 1)
                {
                    break;						// metoda konci
                }
            }
            catch (Exception e)
            {
                convertUI(false,y,u);			// predosli prevod
            }
            System.out.println();
            System.out.println();
        }
    }
    // metoda ktora roby 2.maska/prefix
    public static void prefixUI(boolean que, int y, int u)	// gue: true-od zaciatku,false-predosli prevod y,u= predosli prevod  
    {
        while(true)
        {
            Scanner kb2 = new Scanner(System.in);
            if (que)
            {
                System.out.println("Konvertovať z:");
                System.out.println("    1 Prefix");
                System.out.println("    2 Maska");
                System.out.println("    3 Wildcard");
                y = kb2.nextInt();                      // vyber z moznosti
                System.out.println("Konvertovať do:");  // zobrazovat sa bude ponuka bez moznosti ktora bola uz vybrana
                u = 0;
                if(y == 1)
                {
                    System.out.println("    1 Maska");
                    System.out.println("    2 Wildcard");
                    u = kb2.nextInt();
                    if (u < 0 && u > 3)
                    {
                        System.out.println("Zlý vstup");
                        continue;
                    }
                }
                if(y == 2)
                {
                    System.out.println("    1 Prefix");
                    System.out.println("    2 Wildcard");
                    u = kb2.nextInt();
                    switch(u)
                    {
                        case 1:
                            u = 3;
                            break;
                        case 2:
                            u = 4;
                            break;
                        default:
                            System.out.println("Zlý vstup");
                            continue;
                    }
                }
                if(y == 3)
                {
                    System.out.println("    1 Prefix");
                    System.out.println("    2 Maska");
                    u = kb2.nextInt();
                    switch(u)
                    {
                        case 1:
                            u = 5;
                            break;
                        case 2:
                            u = 6;
                            break;
                        default:
                            System.out.println("Zlý vstup");
                            continue;
                    }
                }
                System.out.println();
            }

            switch (y)
            {
                case 1:
                    if(u == 1)
                    {
                        while (true)
                        {
                            System.out.print("Zadaj prefix: ");
                            int in = kb2.nextInt();
                            if (in >= 0 && in <= 32)
                            {
                                System.out.print("Maska je: ");
                                int[] mask = fromPrefixToMask(in);
                                writeAddress(mask);
                                break;
                            }
                            else
                            {
                                System.out.println("Zlý prefix");
                            }
                        }
                    }
                    if(u == 2)
                    {
                        while (true)
                        {
                            System.out.print("Zadaj Prefix: ");
                            int in = kb2.nextInt();
                            if (in >= 0 && in <= 32)
                            {
                                System.out.print("Wildcard je: ");
                                int[] wildcard = fromPrefixToVildcard(in);
                                writeAddress(wildcard);
                                break;
                            }
                            else
                            {
                                System.out.println("Zlý prefix");
                            }
                        }
                    }
                    break;
                case 2:
                    if(u == 3)
                    {
                        System.out.print("Zadaj masku: ");
                        int[] in = getAddress();
                        System.out.println("Prefix je " + fromMaskToPrefix(in));
                    }
                    if(u == 4)
                    {
                        System.out.print("Zadaj masku: ");
                        int[] in = getAddress();
                        int[] out = fromMaskToVildcard(in);
                        System.out.print("Wildcard je ");
                        writeAddress(out);
                    }
                    break;
                case 3:
                    if(u == 5)
                    {
                        System.out.print("Zadaj wildcard: ");
                        int[] in = getAddress();
                        System.out.println("Prefix je " + fromWildcardToPrefix(in));
                    }
                    if(u == 6)
                    {
                        System.out.print("Zadaj wildcard: ");
                        int[] in = getAddress();
                        int[] out = fromWildcardToMask(in);
                        System.out.print("Maska je ");
                        writeAddress(out);
                    }
                    break;
                default:
                    System.out.println("Zlý vstup");
                    convertUI(true, 0, 0);
            }
            kb2.nextLine();

            System.out.println();
            System.out.println();

            System.out.println("Čo chceš robiť? Pokračovať s nastaveným prevodom = Enter  Nový prevod = 0  Menu = 1");
            String back = kb2.nextLine();
            try {
                int in = Integer.parseInt(back);
                if(in == 0)
                {
                    prefixUI(true, 0, 0);
                }
                if (in == 1)
                {
                    break;
                }
            }
            catch (Exception e)
            {
                prefixUI(false,y,u);
            }
            System.out.println();
            System.out.println();
        }
    }

    //metod for get IPv4 address from user in console
	public static int[] getAddress()
    {
		@SuppressWarnings("resource")
		Scanner kb = new Scanner(System.in);
        String [] inout = kb.nextLine().split("\\.");
        try {
            int[] address = stringArrayToIntArray(inout);
            if(address.length == 4)
            {
                return address;
            }
            else
            {
            	System.out.println("Zadaj adresu so �tyrmi oktetmi");
            	return getAddress();
            }
        }
        catch (Exception e)
        {
            System.out.println("Zadaj iba ��sla");
            return getAddress();
        }
    }
    public static void writeAddress(int[] address)
    {
        for (int i = 0; i < 4; i++)
        {<commit_msg>Version 0.5<commit_after>/*
 * 
 * Autory :   <NAME>
 * 			  Skirka �ubom�r
 * 			  <NAME>
 * 			  <NAME>�
 * 
 */

import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        System.out.println("Vitajte v aplikácii ");
        menu();

    }
    // hlavne menu aplikacie
    public static void menu()
    {
        while (true)
        {
            Scanner kb = new Scanner(System.in);

            System.out.println("Funkcie:");
            System.out.println("    1 Prevod medzi sústavami");
            System.out.println("    2 Maska/Prefix");
            System.out.println("    3 IP Review");
            System.out.print("Vyberte funkciu: ");
            int y;
            try {
                y = kb.nextInt();    // vyber funkcii
            }
            catch (Exception e)
            {
                System.out.println("Zlý vstup.");
                System.out.println();
                System.out.println();
                continue;
            }
            System.out.println();
            switch (y)
            {
                case 1:
                    convertUI(true, 0, 0);
                    break;
                case 2:
                    prefixUI(true, 0, 0);
                    break;
                case 3:
                    ipReviewUI();
                    break;
                default:
                    System.out.println("Zadaj číslo fukcie");
                    menu();
                    break;
            }
        }
    }
    // metoda ktorá roby 1.prevod medzy sústavami
    public static void convertUI(boolean que, int y, int u)		// gue: true-od zaciatku,false-predosli prevod y,u= predosli prevod
    {
        while(true)
        {
            Scanner kb2 = new Scanner(System.in);
            if (que)
            {
                System.out.println("Z ktorej sústavy chceš prevádzať:");
                System.out.println("    1 Binarna");
                System.out.println("    2 Decimálna");
                y = kb2.nextInt();                    // vyber moznosti
                System.out.println("Do ktorej sústavy chceš prevádzať:");	// zobrazovat sa bude ponuka bez moznosti ktora bola uz vybrana
                u = 0;
                if(y == 2)	
                {
                    System.out.println("    1 Binarna");
                    u = kb2.nextInt();				// vyber moznosti
                    u = 1;
                }
                if(y == 1)
                {
                    System.out.println("    1 Decimálna");
                    u = kb2.nextInt();				// vyber moznosti
                    u = 2;
                }
                System.out.println();
            }

            switch (y)
            {
                case 1:
                    if(u == 2)
                    {
                        System.out.print("Zadaj binarne číslo: ");
                        int[] in = getBinNum();
                        System.out.println("Zadané číslo v desiatkovej sústave je: " + fromBinToDec(in));
                    }
                    break;
                case 2:
                    if(u == 1)
                    {
                        System.out.print("Zadaj decimalne číslo: ");
                        int in = kb2.nextInt();
                        System.out.print("Zadané číslo v binárnej sústave je: ");
                        for (int x : fromDecToBin(in))
                        {
                            System.out.print(x);
                        }
                    }

                    break;
                default:
                    System.out.println("Zlý vstup");
                    convertUI(true, 0, 0);
            }
            kb2.nextLine();

            System.out.println();
            System.out.println();

            System.out.println("Čo chceš robiť? Pokračovať s nastaveným prevodom = Enter  Nový prevod = 0  Menu = 1");
            String back = kb2.nextLine();
            try {
                int in = Integer.parseInt(back);
                if(in == 0)
                {
                   convertUI(true, 0, 0);		// metoda sa zacne vykonavat od zaciatku
                }
                if (in == 1)
                {
                    break;						// metoda konci
                }
            }
            catch (Exception e)
            {
                convertUI(false,y,u);			// predosli prevod
            }
            System.out.println();
            System.out.println();
        }
    }
    // metoda ktora roby 2.maska/prefix
    public static void prefixUI(boolean que, int y, int u)	// gue: true-od zaciatku,false-predosli prevod y,u= predosli prevod  
    {
        while(true)
        {
            Scanner kb2 = new Scanner(System.in);
            if (que)
            {
                System.out.println("Konvertovať z:");
                System.out.println("    1 Prefix");
                System.out.println("    2 Maska");
                System.out.println("    3 Wildcard");
                y = kb2.nextInt();                      // vyber z moznosti
                System.out.println("Konvertovať do:");  // zobrazovat sa bude ponuka bez moznosti ktora bola uz vybrana
                u = 0;
                if(y == 1)
                {
                    System.out.println("    1 Maska");
                    System.out.println("    2 Wildcard");
                    u = kb2.nextInt();
                    if (u < 0 && u > 3)
                    {
                        System.out.println("Zlý vstup");
                        continue;
                    }
                }
                if(y == 2)
                {
                    System.out.println("    1 Prefix");
                    System.out.println("    2 Wildcard");
                    u = kb2.nextInt();
                    switch(u)
                    {
                        case 1:
                            u = 3;
                            break;
                        case 2:
                            u = 4;
                            break;
                        default:
                            System.out.println("Zlý vstup");
                            continue;
                    }
                }
                if(y == 3)
                {
                    System.out.println("    1 Prefix");
                    System.out.println("    2 Maska");
                    u = kb2.nextInt();
                    switch(u)
                    {
                        case 1:
                            u = 5;
                            break;
                        case 2:
                            u = 6;
                            break;
                        default:
                            System.out.println("Zlý vstup");
                            continue;
                    }
                }
                System.out.println();
            }

            switch (y)
            {
                case 1:
                    if(u == 1)
                    {
                        while (true)
                        {
                            System.out.print("Zadaj prefix: ");
                            int in = kb2.nextInt();
                            if (in >= 0 && in <= 32)
                            {
                                System.out.print("Maska je: ");
                                int[] mask = fromPrefixToMask(in);
                                writeAddress(mask);
                                break;
                            }
                            else
                            {
                                System.out.println("Zlý prefix");
                            }
                        }
                    }
                    if(u == 2)
                    {
                        while (true)
                        {
                            System.out.print("Zadaj Prefix: ");
                            int in = kb2.nextInt();
                            if (in >= 0 && in <= 32)
                            {
                                System.out.print("Wildcard je: ");
                                int[] wildcard = fromPrefixToVildcard(in);
                                writeAddress(wildcard);
                                break;
                            }
                            else
                            {
                                System.out.println("Zlý prefix");
                            }
                        }
                    }
                    break;
                case 2:
                    if(u == 3)
                    {
                        System.out.print("Zadaj masku: ");
                        int[] in = getAddress();
                        System.out.println("Prefix je " + fromMaskToPrefix(in));
                    }
                    if(u == 4)
                    {
                        System.out.print("Zadaj masku: ");
                        int[] in = getAddress();
                        int[] out = fromMaskToVildcard(in);
                        System.out.print("Wildcard je ");
                        writeAddress(out);
                    }
                    break;
                case 3:
                    if(u == 5)
                    {
                        System.out.print("Zadaj wildcard: ");
                        int[] in = getAddress();
                        System.out.println("Prefix je " + fromWildcardToPrefix(in));
                    }
                    if(u == 6)
                    {
                        System.out.print("Zadaj wildcard: ");
                        int[] in = getAddress();
                        int[] out = fromWildcardToMask(in);
                        System.out.print("Maska je ");
                        writeAddress(out);
                    }
                    break;
                default:
                    System.out.println("Zlý vstup");
                    convertUI(true, 0, 0);
            }
            kb2.nextLine();

            System.out.println();
            System.out.println();

            System.out.println("Čo chceš robiť? Pokračovať s nastaveným prevodom = Enter  Nový prevod = 0  Menu = 1");
            String back = kb2.nextLine();
            try {
                int in = Integer.parseInt(back);
                if(in == 0)
                {
                    prefixUI(true, 0, 0);
                }
                if (in == 1)
                {
                    break;
                }
            }
            catch (Exception e)
            {
                prefixUI(false,y,u);
            }
            System.out.println();
            System.out.println();
        }
    }
    public static void ipReviewUI()
    {
        Scanner kb7 = new Scanner(System.in);
        System.out.print("Zadaj IPv4 adresu: ");
        int[] address = getAddress();
        System.out.print("Zadaj prefix: ");
        int prefix = kb7.nextInt();
        System.out.println();

        System.out.print("Maska je: ");
        writeAddress(fromPrefixToMask(prefix));
        System.out.println();

        System.out.print("Network adress: ");
        writeAddress(getNetOrBroAddress(address,prefix,true));
        System.out.println();

        System.out.print("Broadcast adress: ");
        writeAddress(getNetOrBroAddress(address,prefix,false));
        System.out.println();

        System.out.println("Number of address: " + getSpaceAddress(prefix));

        System.out.println("Number of address for devices: " + (getSpaceAddress(prefix) - 2));

        System.out.print("The first usable adress: ");
        writeAddress(getFirstOrLastAddress(address,prefix,true));
        System.out.println();

        System.out.print("The last usable adress: ");
        writeAddress(getFirstOrLastAddress(address,prefix,false));
        System.out.println();

        kb7.nextLine();
        kb7.nextLine();
    }
    //metod for get IPv4 address from user in console
	public static int[] getAddress()
    {
		@SuppressWarnings("resource")
		Scanner kb = new Scanner(System.in);
        String [] inout = kb.nextLine().split("\\.");
        try {
            int[] address = stringArrayToIntArray(inout);
            if(address.length == 4)
            {
                return address;
            }
            else
            {
            	System.out.println("Zadaj adresu so �tyrmi oktetmi");
            	return getAddress();
            }
        }
        catch (Exception e)
        {
            System.out.println("Zadaj iba ��sla");
            return getAddress();
        }
    }
    public static void writeAddress(int[] address)
    {
        for (int i = 0; i < 4; i++)
        {
{'fraction_non_alphanumeric': 0.09919427772753432, 'fraction_numerical': 0.008509413795938501, 'mean_word_length': 0.778029527846806, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7339742', 'n_tokens_mistral': 6601, 'n_tokens_neox': 5962, 'n_words': 1262}