<file_sep>package com.javabk.han;

import java.util.Scanner;
import java.lang.String;
public class QuanXe {
    public static void main(String[] args) {
        int[] args1 = new int[]{1,2,3,4,5,6,7,8};
        Scanner scn = new Scanner(System.in);
        String vitri;
        char[] args2 = new char[]{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'};
        String[][] arr = new String[8][8];
        for (int i = 0; i < args1.length; i++) {
            for (int j = 0; j < args2.length; j++) {
                arr[i][j] = args1[i] + String.valueOf(args2[j]);
                System.out.print(arr[i][j]);
                if (j == arr.length - 1) System.out.println();
                //-------------------------------------

            }
        }
        vitri=scn.next();
        for(int i=0;i<args1.length;i++) {
            if(args1[i]!=(int)vitri.charAt(0)-48) System.out.print(args1[i]+String.valueOf(vitri.charAt(1))+"\t");
        }
        for(int i=0;i<args2.length;i++){
            if(args2[i]!=vitri.charAt(1)) System.out.print(String.valueOf(vitri.charAt(0))+args2[i]+"\t");
        }
    }
}
<file_sep>    package com.javabk.thu;

import java.util.Scanner;

public class CauLenhLap {
    public static void soNguyenTo(){
        Scanner scanner = new Scanner(System.in);
        int number =2;
        int demSoNguyenTo= 0;
        while (demSoNguyenTo<20){
            for (int i = 2; i <number -1 ; i++) {
                if (number%i ==0){
                    number++;
                    i=2;
                }
            }
            System.out.println(number + " ");
            demSoNguyenTo++;
            number++;
        }
    }
    public static void hienThiCacLoaiHinh(){
        Scanner scanner = new Scanner(System.in);
        System.out.println("Menu");
        System.out.println("1. Print the rectangle");
        System.out.println("2. Print the square triangle");
        System.out.println("3. Print isosceles triangle");
        System.out.println("0. Exit");
        System.out.println("Enter your choice: ");
        while (true) {
            int choice = scanner.nextInt();
            switch (choice) {
                case 1:
                    System.out.println("Draw the square");
                    System.out.println("* * * * * *");
                    System.out.println("* * * * * *");
                    System.out.println("* * * * * *");
                    System.out.println("* * * * * *");
                    break;
                case 2:
                    System.out.println("Draw the triangle");
                    System.out.println("******");
                    System.out.println("*****");
                    System.out.println("****");
                    System.out.println("***");
                    System.out.println("**");
                    System.out.println("*");
                    break;
                case 3:
                    System.out.println("Draw the rectangle");
                    System.out.println("* * * * * ");
                    System.out.println(" * * * * ");
                    System.out.println("  * * * ");
                    System.out.println("    *  ");
                    break;
                case 0:
                    System.exit(0);
                default:
                    System.out.println("No choice!");
            }
        }

    }
    public static void soNguyenToNhoHon100() {
        Scanner scanner = new Scanner( System.in);
        System.out.println("Các số nguyên tố nhỏ hơn 100 là: ");
        for (int i = 0; i < 100; i++) {
            if (kiemtrasonguyen(i)) {
                System.out.print(i + " ");
            }
        }
    }
    public static boolean kiemtrasonguyen(int n) {
        if (n < 2) {
            return false;
        }
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }
    public static void UCLN(){
        Scanner scanner = new Scanner(System.in);
        int a,b;
        System.out.println("nhap so nguyen duong a la:");
        a = scanner.nextInt();

        System.out.println("nhap so nguyen duong b la:");
        b = scanner.nextInt();
        a = Math.abs(a);
        b = Math.abs(b);
        if (a ==0 || b==0);
        while (a != b) {
            if (a > b)
                a = a - b;
            else
                b = b - a;
        }
        System.out.println("UCLN:" +a);
    }
}
<file_sep>package com.ateach.pdf2.collectionFrameWork.hashandtree;

import java.util.Map;
import java.util.TreeMap;

public class TreeMapTest {
    static void insertAndPrint(TreeMap<Integer, String> map) {
        int[] array = {1, -1, 0, 2, -2};
        for (int x : array) {
            map.put(x, Integer.toString(x));
        }
        for (int k : map.keySet()) {
            System.out.print(k + ", ");
        }
    }

    // Driver method to test above method
    public static void main(String[] args) {
//        TreeMap<Integer, String> map = new TreeMap<Integer, String>();
//        insertAndPrint(map);

        TreeMap<Integer, Integer> hv = new TreeMap<Integer, Integer>();
        hv.put(1, 7);
        hv.put(5, 9);
        hv.put(4, 3);
        for (Map.Entry v : hv.entrySet()) {
            System.out.println("value: " + v.getValue()+ "key  "+v.getKey());

        }
    }
}
<file_sep>package com.javabk.khai;

import java.util.Scanner;

public class TimGiaTriNhoNhatTrongMang {


    public static void main(String[] args) {

        int[] array = new int[10];
        Scanner sc = new  Scanner(System.in);


        System.out.println("Nhap gia tri cho mang :");
        for (int i = 0; i < array.length; i++) {
            array[i] = sc.nextInt();
        }

        int a = array[0];
        for (int i = 0; i < array.length; i++){
            if (a > array[i]) {
                a = array[i];
            }
        }
        System.out.println("Gia tri nho nhat trong mang la : \t" +a);

    }
}
<file_sep>package com.ateach.pdf2.oop.usequizabstractvsinterface.fruit;


import com.ateach.pdf2.oop.usequizabstractvsinterface.edible.Edible;

public abstract class Fruit implements Edible {

}
<file_sep>package com.javabk.khai;
import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;
public class Method {

        public static void main(String[] args) {

            Scanner scan = new Scanner(System.in);

            System.out.println("Bai tap chuoi Pentagonal");
            int n;
            System.out.println("Nhap so n");

            n = scan.nextInt();
            System.out.println("Chuoi Pentagonal: ");
            Pentagonal(n);

            System.out.println("------------------------------");

            System.out.println("Bai tap tong cac phan tu trong 1 so");
            System.out.println("Nhap so nguyen: ");
            int x = scan.nextInt();
            System.out.println("Tong cac so trong so nguyen la: ");
            System.out.println(sumDigits(x));

            System.out.println("-------------------------------------");

            System.out.println("Bai tap sao xep 3 so thuc");
            System.out.println("Nhap 3 so thuc");
            double n1, n2, n3;
            n1 = scan.nextDouble();
            n2 = scan.nextDouble();
            n3 = scan.nextDouble();
            System.out.println("sap xep 3 so: ");
            displaySortedNumbers(n1, n2, n3);

            System.out.println("\n--------------------------------------");

            System.out.println("Bai tap ve so doi xung");
            System.out.println("Nhap mot so a bat ky: ");
            int a = scan.nextInt();
            System.out.println("So dao nguoc cua so x: " + reverse(a));
            System.out.println("Xet tinh doi xung cua x: " + isPalindrome(a));

            System.out.println("--------------------------------------");

            System.out.println("Bai tap chuyen doi tu feet qua metters");
            System.out.println("Nhap so feet con chuyen: ");
            double feet = scan.nextDouble();
            System.out.println(feet + " feet = " + feetToMeter(feet) + " metters");
            System.out.println("Nhap so metters can chuyen: ");
            double metters = scan.nextDouble();
            System.out.println(metters + " metters = " + meterToFeet(metters) + " feet");

            System.out.println("---------------------------------------");

            System.out.println("Kiem tra so nguyen to");
            System.out.println("Nhap mot so can kiem tra: ");
            int soNT=scan.nextInt();
            System.out.println("So vua nhap la so nguyen to: "+isPrime(soNT));

            System.out.println("--------------------------------------");

            System.out.println("Bai tap hien thi ma tran nhi phan");
            System.out.println("Nhap canh cua ma tran");
            int canh=scan.nextInt();
            System.out.println("Ma tran nhi phan "+canh+"x"+canh+" :");
            printMatrix(canh);

            System.out.println("-------------------------------------");

            System.out.println("Bai tap dem so ki tu trong chuoi");
            System.out.println("Nhap vao 1 chuoi");
            String s=scan.nextLine();
            System.out.println("So ki tu trong chuoi la: "+countLetters(s));

            System.out.println("----------------------------------------");

            System.out.println("Bai tap dem so ngay tu nam XXXX den nam YYYY ");
            System.out.println("Nhap nam thu 1: ");
            int year1=scan.nextInt();
            System.out.println("Nhap nam thu 2: ");
            int year2= scan.nextInt();
            System.out.println("So ngay trong khoang thoi gian tu nam "+year1+" den nam "+year2+" la: "+countNumberOfDaysInYeartoYear(year1,year2)+" ngay");

            System.out.println("--------------------------------------------");
        }

        public static void Pentagonal(int x) {
            int pen;
            for (int i = 1; i < x; i++) {
                pen = i * (3 * i - 1) / 2;
                System.out.print(pen + ", ");
            }
            System.out.println(x * (x * 3 - 1) / 2);
        }

        public static long sumDigits(long n) {
            int count = 0;
            while (n > 0) {
                count += n % 10;
                n = n / 10;
            }
            return count;
        }

        public static void displaySortedNumbers(double num1, double num2, double num3) {

            double temp;
            if (num1 > num2) {
                temp = num1;
                num1 = num2;
                num2 = temp;
            }
            if (num2 > num3) {
                temp = num2;
                num2 = num3;
                num3 = temp;
            }
            if (num1 > num2) {
                temp = num1;
                num1 = num2;
                num2 = temp;
            }
            System.out.print(num1 + ",");
            System.out.print(num2 + ",");
            System.out.print(num3);
        }

        public static int reverse(int number) {
            int count = 0;
            while (number > 0) {
                count = count * 10 + number % 10;
                number /= 10;
            }
            return count;
        }

        public static boolean isPalindrome(int number) {
            if (reverse(number) == number) return true;
            else return false;
        }

        public static double feetToMeter(double feet) {
            return 0.305 * feet;
        }

        public static double meterToFeet(double meter) {
            return meter * 3.279;
        }

        public static boolean isPrime(int number){
            int count=0;
            for (int i=1;i<Math.sqrt(number);i++){
                if (number%i==0){
                    count+=1;
                }
            }
            if (count==1) return true;
            else return false ;
        }

        public static void printMatrix(int n){
            int[][] matrix=new int[n][n];
            Random rand = new Random();
            for (int i =0;i<matrix.length;i++){
                for (int j=0;j<matrix[i].length;j++){
                    matrix[i][j]=rand.nextInt(2);
                }
            }
            for (int i=0;i<matrix.length;i++)
                System.out.println(Arrays.toString(matrix[i]));
        }

        public static int countLetters(String s){
            int count=0;
            for (int i=0;i<s.length();i++){
                count+=1;
            }

            return count;
        }
        public static boolean ktNamNhuan(int year) {
            if (year % 4 == 0 && year % 100 != 0) {
                return true;
            }
            else{
                if (year % 400 == 0 && year % 100 == 0) {
                    return true;
                }
                else {
                    return false;
                }
            }

        }
        public static int numberOfDaysInAYear(int year){
            int day;
            if (ktNamNhuan(year)){
                day=366;
            }
            else day=365;

            return day;
        }

        public static int countNumberOfDaysInYeartoYear(int year1, int year2){
            int count=0;
            for (int i=year1;i<=year2;i++){
                count+=numberOfDaysInAYear(i);
            }

            return count;
        }
}
<file_sep>package com.ateach.pdf1.quizz.reviewPf1;

public class ArrayMax {
    int arrayMaximalAdjacentDifference(int[] inputArray) {
        int max=0;
        for( int i = 1 ; i < inputArray.length ; i++ ){
            max = Math.max(max, Math.abs(inputArray[i] - inputArray[i-1]));
        }
        return max;
    }
}
<file_sep>package com.ateach.pdf1.basic.method;

public class BaiTap {
    /*  #1. Given the string, check if it is a palindrome.*/
    public static boolean isPalindrome(String str) {

        boolean isPa = false;
        System.out.println(str.length());
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) != str.charAt(str.length() - i - 1)) {
                isPa = false;
                break;
            } else {
                isPa = true;
            }
        }
       return isPa;

    }
/* #2.Given n and firstNumber, find the number which is written in the radially opposite position to firstNumber.*/

/* #3. After they became famous, the CodeBots all decided to move to a new building and live together.
    The building is represented by a rectangular matrix of rooms. Each cell in the matrix contains
    an integer that represents the price of the room. Some rooms are free (their cost is 0),
    but that's probably because they are haunted, so all the bots are afraid of them. That is why any room
    that is free or is located anywhere below a free room in the same column is not considered suitable for
    the bots to live in. Help the bots calculate the total price of all the rooms that are suitable for them.*/

    public static int giaPhong() {
        int[][] rooms = {{0, 1, 1, 2},
                         {0, 5, 0, 0},
                         {2, 0, 3, 3}};
        int sum = 0;
        for (int cot = 0; cot < rooms[0].length; cot++) {
            for (int hang = 0; hang < rooms.length; hang++) {
                if (rooms[hang][cot] == 0) {
                    break;
                } else {
                    sum = sum + rooms[hang][cot];
                }
            }
        }
        return sum;
    }
}
<file_sep>package com.ateach.pdf2.oop.exercise;

public class Quiz1 {
    final void useFinal(){
        System.out.println("final method");
    }
    void nonUseFinal(){
        System.out.println("non filnal method");
    }
}

class Exam extends Quiz1{

}<file_sep>package com.ateach.pdf2.oop.exercise;

interface Quiz5a {
    int id = 100; //must initialed
    //protected String name;
    //private String name;
    public String name = "name";

}


interface Quiz5b {
    String address = "DN";
}


class TestQuiz5 {
    public static void main(String[] args) {
        System.out.println(Quiz5a.id);
    }
}

//c.
class implementTwoInterface implements Quiz5a, Quiz5b {
    public static void main(String[] args) {
        System.out.println("id: " + Quiz5a.id + "address: " + Quiz5b.address);
    }
}
// d.

abstract class AbsClass implements Quiz5b {
    abstract void show();
}



<file_sep>package com.ateach.pdf1.project.furamaStruct;

import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoField;
import java.util.Scanner;

public class FuramaProject {
    private static Scanner scn = new Scanner(System.in);
    static final String TIME_OPEN = "9PM";

    public static void main(String[] args) {
        VillaManager vl = new VillaManager();
        int enter;
        do{
            System.out.println("-------------------MENU--------------------");
            System.out.println("*    1. Check in                          *");
            System.out.println("*    2. Swimming Pool Opening Times       *");
            System.out.println("*    3. Service                           *");
            System.out.println("*       3.1. Swimming Pool Service        *");
            System.out.println("*       3.2. Rent day                     *");
            System.out.println("*    4. ManagerPerson Villa                     *");
            System.out.println("*       4.1. Add new bed and swimming pool*");
            System.out.println("*       4.2. Display info villa           *");
            System.out.println("*    0. Exit                              *");
            System.out.println("*    4. Continues                         *");
            System.out.println("-------------------------------------------");
            System.out.print("    Please choose:   ");
            String choose = scn.next();
            switch (choose){
                case "1":
                    System.out.println("Enter name of customer: ");
                    String customerName = scn.next();
                    System.out.println("Enter age of customer: ");
                    int  customerAge = scn.nextInt();
                    System.out.println("Enter V (Villa) or H(House)");
                    String type = scn.next();
                    System.out.println("Enter day");
                    int day = scn.nextInt();
                    infoCustomer(customerName,customerAge);
                    caculatorForRent(type.toUpperCase(),day);
                    break;
                case "2":
                    swimmingPoolOpenTimes(TIME_OPEN);
                    break;
                case "3.1":
                    System.out.println("Enter time (format: hh:mm): ");
                    String time = scn.next();
                    swimmingPoolService(time);
                    break;
                case "3.2":
                    System.out.println("Enter money");
                    float money = scn.nextFloat();
                    System.out.println("Enter V (Villa) or H(House)");
                    String types = scn.next();
                    dayForRent(types.toUpperCase(), money);
                    break;
                case "4.1":
                    System.out.println("Enter total villa in furamaOop resort");
                    int total = scn.nextInt();
                    vl.addNewVilla(total);
                    break;
                case "4.2":
                    vl.displayVillaInfo();
                    break;
                default:
                    System.out.println("Please enter valid number:");
                    break;
            }
            System.out.println("Enter 0 to exit - enter 4 to continues");
            enter = scn.nextInt();
        }while (enter != 0);
    }





    public static void infoCustomer(String name, int age){
        System.out.println("-----------Check in info-----------");
        System.out.println("Name:\t" + name);
        System.out.println("Age:\t "+ age);
    }

    public static void swimmingPoolOpenTimes(String time ){
        System.out.println("Swimming pool open at: "+time);
    }

    public static void swimmingPoolService(String time ){
        LocalTime localTime = LocalTime.parse(time, DateTimeFormatter.ofPattern("HH:mm"));
        int hour = localTime.get(ChronoField.CLOCK_HOUR_OF_DAY);
        int minute = localTime.get(ChronoField.MINUTE_OF_HOUR);
        int mSum = 9*60;
        int cSum = hour * 60 + minute;
        int rTime = mSum - cSum;
        String message ="";
        if(rTime !=0){
            int hTime = rTime/60;
            int mTime = rTime%60;
            if(hTime != 0 && mTime !=0){
                message = message + hTime +" house " +mTime +" minutes";
            }else if(hTime == 0 && mTime !=0){
                message = message  + mTime +" minutes";
            }
            System.out.println("Please wait " + message);
        }else{
            System.out.println("Welcome!!!");
        }
    }

    public static void caculatorForRent(String type, int date){
        switch (type){
            case "V":
                System.out.println("You pay "+rentCharge(type, date)+" USD/" +date+" days");
                break;
            case "H":
                System.out.println("You pay "+rentCharge(type, date)+"USD/" +date+" days");
                break;
            default:
                System.out.println("No service");
                break;
        }
    }

    public static float rentCharge(String type, int date){
        float cost = 0;
        if (type.equals("V")){
            cost =  10*(float)date;
        }else if(type.equals("H")){
            cost =  5*(float)date;
        }
        return cost;
    }

    public static void dayForRent(String type, float money){
        switch (type){
            case "V" :
                System.out.println("You have "+ (int)money/10+" days ");
                break;
            case "H":
                System.out.println("You have "+(int)money/5+" days");
                break;
        }
    }
}

<file_sep>package com.ateach.pdf2.oop.staticexample.example1;

public class ExampleStatic {
    int schoolId = 111;
    static String schoolName = "Oxford";

    void schoolInfo(){
        System.out.println("id" + schoolId + "name "+ schoolName);
    }
}

class Manager {
    public static void main(String[] args) {
        System.out.println(ExampleStatic.schoolName);

        ExampleStatic ex = new ExampleStatic();
        ex.schoolInfo();
        System.out.println(ex.schoolId);
//        System.out.println(ex.);
    }
}
<file_sep>package com.javabk.dung;

import java.util.Scanner;

public class XoaPhanTu {
    static Scanner sc = new Scanner(System.in);
    public static void xoaPhanTuVaoMang(){
            int kichThuoc;
            boolean kiemTra;
            //Nhập mảng
            do {
                System.out.print("Nhap so phan tu cua mang: 1");
                kichThuoc = sc.nextInt();
                if (kichThuoc <= 0) {
                    kiemTra = true;
                } else kiemTra = false;
            } while (kiemTra);
            int[] array = new int[kichThuoc];
            System.out.println("Nhap lan luot cac phan tu trong mang: ");
            nhapMang(array);
            //Nhập giá trị cần xóa và kiểm tra có bao nhiêu giá trị đó trong mảng
            int soCanXoa, count=0;
            boolean ktSoCanXoa = true;
            do {
                System.out.print("Nhập giá trị cần xóa ");
                soCanXoa = sc.nextInt();
                for (int i = 0; i < array.length; i++) {
                    if (soCanXoa == array[i]) {
                        ktSoCanXoa = false;
                        count++;
                    }
                }
                if (ktSoCanXoa == true) {
                    System.out.println("Không tồn tại số " + soCanXoa + " trong mảng. Vui lòng nhập lại");
                }
            } while (ktSoCanXoa);
            //Tiến hành xóa
            int doDaiMoi = array.length-count;
            int[] arrayMoi = new int[doDaiMoi];
            int j=0;
            for(int xetMangMoi=0; xetMangMoi<arrayMoi.length; xetMangMoi++){
                if (soCanXoa != array[j]){
                    arrayMoi[xetMangMoi]=array[j];
                }else {
                    j++;
                    arrayMoi[xetMangMoi] = array[j];
                }
                j++;
            }
            //In ra mảng sau khi xóa
            System.out.println("Mảng sau khi xóa là:");
            for (int scan : arrayMoi) {
                System.out.print(scan + " ");
            }
        }

        public static void nhapMang(int[] mang){
            for (int i=0; i<mang.length; i++){
                mang[i] = sc.nextInt();
            }
        }
}
<file_sep>package com.ateach.pdf2.oop.packageexample.package2;

import com.ateach.pdf2.oop.packageexample.package1.*; // path access to package 1

public class ClassOfPackage2 {

    public static void main(String[] args) {
        ClassOfPackage1 objPk1 = new ClassOfPackage1();
        System.out.println(objPk1.variablePackage1);
        objPk1.info();
    }
}
<file_sep>package com.javabk.han.newpkg;

public class Recusiver1 {
    public static void main(String[] srgs) {
        System.out.println(Sum(3));
    }

    public static float Sum(float n) {
        if (n == 1)
            return 1;
        float tong =(1 / n) + Sum(n - 1);
        return tong;
    }
}
<file_sep>package com.ateach.pdf2.fileExample;

import java.io.File;
import java.util.*;

public class FinePercentVowel {
    public static void readContentFromFile(int n) {
        String pathName = "E:\\testfile\\vowel.txt";
        File fl = new File(pathName);
        ArrayList<String> sr = new ArrayList<>();
        try {
            Scanner sc = new Scanner(fl);
            while (sc.hasNextLine()) {
                sr.add(sc.nextLine());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        String[] st = new String[sr.size()];
        for (int i = 0; i < sr.size(); i++) {
            st[i] = sr.get(i);
        }
        for (int j = 0; j < st.length; j++) {
            System.out.println("Line " + (j + 1));
            fineVowel(st[j], n);
            System.out.println();

        }
    }

    public static void fineVowel(String st, int n) {
        String[] stn = new String[st.length() - n];
        for (int i = 0; i < st.length() - n; i++) {
            System.out.println(st);
            stn[i] = st.charAt(i) + "" + st.charAt(i + 1) + "" + st.charAt(i + 2);

            int total = 0;
            for (int j = 0; j < stn[i].length() - 1; j++) {
                if (stn[i].charAt(j) == 'a' || stn[i].charAt(j) == 'e' || stn[i].charAt(j) == 'i' || stn[i].charAt(j) == 'o' || stn[i].charAt(j) == 'u' || stn[i].charAt(j) == 'y') {
                    total = total + 1;
                }
            }
            System.out.println(stn[i] + " (freq = " + total + "/3 = " + (float) total / 3 * 100 + ")");
        }
    }

    public static void main(String[] args) {
        readContentFromFile(3);
    }
}
<file_sep>package com.ateach.designpattern.stragety;

public interface QuackBehavior {
    public void quack();
}
<file_sep>package com.ateach.pdf1.basic.vonglap;

public class SoNguyenTo {
    // TODO code application logic here


    public static void inRaSoNguyenTo(){

      for(int i = 0; i < 20; i ++){
          if(kiemTraSoNguyenTo2(i)){
              System.out.println(i);
          }
      }
    }

    public static boolean kiemTraSoNguyenTo(int n){
        if( n == 0 || n == 1) return false;
        for(int i =  2; i<= n -1; i ++){
            if ( n % i == 0) return false;
        }
        return true;
    }
   public static boolean kiemTraSoNguyenTo2(int n)
    {
        // Neu n < 2 thi khong phai la SNT
        if (n < 2){
            return false;
        }

        // Neu n = 2 la SNT
        if (n == 2){
            return true;
        }

        // Neu n la so chan thi ko phai la SNT
        if (n % 2 == 0){
            return false;
        }

        // Lap qua cac so le
        for (int i = 3; i < (n - 1); i += 2){
            if (n % i == 0){
                return false;
            }
        }

        return true;
    }
}
<file_sep>package com.ateach.pdf2.oop.accessexample.privateaccess;

 class PrivateAcess {
    private int data = 40;

    private void msg() {
        System.out.println("Hello java");
    }
}

 class Simple {
    public static void main(String args[]) {
        PrivateAcess obj = new PrivateAcess();

        //   System.out.println(obj.data); // can't access to field private
        //   obj.msg(); //// can't access to method private

        // we will access private method and field through geter and setter;
    }
}<file_sep>package com.ateach.pdf2.oop.usequizabstractvsinterface.animal;

public abstract class Animal {
    public abstract String makeSound();
}
<file_sep>package com.ateach.pdf2.collectionFrameWork.stackandqueu;

import java.util.ArrayList;
import java.util.Stack;

class StackCls {
    public static void main(String[] args) {

        Stack<Integer> st = new Stack<Integer>();

        st.push(1);
        st.push(2);
        st.push(3);

        for (Integer i : st) {
            System.out.println(i);
        }

//        System.out.println(st.toArray().toString());
        System.out.println("pop method: " + st.pop()); // Trả về phần tử đầu tiên của Stack, Và xóa nó ra khỏi stack
        System.out.println("peek method: " + st.peek()); //Trả về phần tử đầu tiên của Stack, nhưng không xóa nó ra khỏi stack
//        System.out.println("serarh"+st.search(1));
//
        for (Integer i : st) {
            System.out.println(i);
        }
    }
}
<file_sep>package com.ateach.pdf2.oop.grocery;

public class Condition implements DiscountCondition{
    private String nameOfCustomer;

    private String discountName;
    private double discountAmount;

    public Condition(String nameOfCustomer, String discountName, double discountAmount) {
        this.nameOfCustomer = nameOfCustomer;
        this.discountName = discountName;
        this.discountAmount = discountAmount;
    }

    public boolean willGetDiscount(){
        return nameOfCustomer != null && nameOfCustomer.equals(discountName);
    }

    @Override public String getNameOfCondition() {
        return "Condition";
    }

    public double getDiscountAmount() {
        return discountAmount;
    }
}
<file_sep>package com.ateach.pdf1.project.furamaOop;

public class SwinmmingPool {
}
<file_sep>package com.ateach.pdf1.project.furamaStruct;

import java.util.Scanner;

public class VillaManager {
    static int[][] villa = null;

    public static void addNewVilla(int totalVilla) {
        villa = new int[totalVilla][2];
        Scanner scn = new Scanner(System.in);
        for (int i = 0; i < villa.length; i++) {
            System.out.println("Enter total bed & total swimming pool of villa " + (i + 1));
            for (int j = 0; j < villa[i].length; j++) {
                villa[i][j] = scn.nextInt();
            }
        }
    }

    public static void displayVillaInfo() {
        System.out.println("villa ----------Bed----Swimming pool");
        for (int i = 0; i < villa.length; i++) {
            System.out.print("Villa " + (i + 1) + "\t\t\t");
            for (int j = 0; j < villa[i].length; j++) {
                System.out.print(villa[i][j] + "\t\t\t");
            }
            System.out.println();
        }
    }
}
<file_sep>package com.ateach.pdf2.orderAgo;

public class SortArrayCharacter {
    String[] sortByLength(String[] inputArray) {
        int i, j, k;
        String swap;
        for (i = 0; i < inputArray.length; i++)
        {
            for (j = i; j < inputArray.length; j++)
            {
                if (inputArray[i].length() > inputArray[j].length())
                {
                    for (k = j; k > i; k--)
                    {
                        swap = inputArray[k];
                        inputArray[k] = inputArray[k-1];
                        inputArray[k-1] = swap;
                    }
                }
            }
        }
        return inputArray;
    }
}
<file_sep>package com.ateach.pdf1.quizz.reviewPf1;

public class almostIncreasingSequence {
    boolean almostIncreasingSequence(int[] sequence) {
        boolean issq = true;
        for(int i = 0; i <sequence.length-1; i ++){
            if((sequence[i+1]-sequence[i]) ==1){
                issq = true;
            }else{
                issq = false;
                break;
            }
        }
        return issq;
    }
}
<file_sep>//package com.ateach.pdf1.basic.array;
//
//import org.junit.jupiter.api.Test;
//
//import java.util.Arrays;
//
//class ContructArrayTest {
//
//    @Test
//    void constructArray() {
//        ContructArray ct = new ContructArray();
//        System.out.println(Arrays.toString(ct.constructArray(7)));
//
//
//    }
//}<file_sep>package com.ateach.pdf2.oop.accessexample.defaultaccess.defaultpackage1;

public class DefaultClassPackge1 {
    int data = 10; // default modifier field (default access modifier field)

    void msg() { // default modifier method (default access modifier method)
        System.out.println("Hello");
    }
}


// access default modifier because DefaultInPackage in same package
// with DefaultClassPackge1 have default modifier field and method default modifier
class DefaultInPackage {
    public static void main(String args[]) {
        DefaultClassPackge1 obj = new DefaultClassPackge1();
        System.out.println(obj.data);
        obj.msg();
    }
}



<file_sep>package com.javabk.khai;

import java.util.Scanner;

public class XoaPhanTuTrongMang {

    public static void main(String[] args) {

        int[] array = new int[10];
        Scanner sc = new  Scanner(System.in);

        System.out.println("Nhap gia tri cho mang :");
        for (int i = 0; i < array.length; i++) {
            array[i] = sc.nextInt();
        }

        int x, a = 0, b = 0 ;


        System.out.println("Nhap phan tu muon xoa :");
        x = sc.nextInt();

            for (int i = 0; i < array.length; i++) {
                if (x == array[i]) {
                    a = i;
                    break;
                }
            }

            for (int i = a; i < array.length; i++){
                if(i == array.length-1){
                    array[i] = 0;
                    break;
                }

                b = array[i + 1];
                array[i] = b;

            }

        for (int i = 0; i < array.length; i++){
            System.out.println(array[i]);
        }
    }
}
<file_sep>package com.javabk.han;

public class SuitableRoom {
    public static void main(String[] args) {
        System.out.println(suitableRoom());

    }

    public static int suitableRoom() {
        int[][] args = new int[][]{{1, 1, 1, 0},
                                   {0, 5, 0, 5},
                                   {2, 1, 3, 10}};
        int sum = 0;
        for (int i = 0; i < args.length; i++) {
            for (int j = 0; j < args.length; j++) {
                if (args[i][j] == 0) {
                    if ((i + 1) > args.length - 1){
                        continue;
                    } else{
                        args[i + 1][j] = 0;
                    }
                }
                sum += args[i][j];
            }
        }
        return sum;
    }
}
<file_sep>//package com.ateach.pdf2.oop.random;
//
//import org.junit.jupiter.api.Test;
//
//class RandomOopTest {
//
//    @Test
//    void getRandomValue() {
//        RandomOop ob = new RandomOop(1000);
//        ob.getRandomValue();
//    }
//}<file_sep>package com.ateach.pdf2.fileInputStream;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

public class FileOutputStreams {
    public static void main(String[] args) {
        String data = "This is an example of writing data to a file.";
        File file = new File("outfile.txt");
        try {
            java.io.FileOutputStream fileOutputStream = new java.io.FileOutputStream(file);
            fileOutputStream.write(data.getBytes());
            fileOutputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
<file_sep>package com.ateach.pdf2.collectionFrameWork.stackandqueu;

import java.util.Stack;

class Parentheses {
    private static final char L_PAREN = '(';
    private static final char R_PAREN = ')';
    private static final char L_BRACE = '{';
    private static final char R_BRACE = '}';
    private static final char L_BRACKET = '[';
    private static final char R_BRACKET = ']';

    //mystack = {(
//    String st1 = "[()]{()}{}";

    public static boolean checkParen(String s) {
        Stack<Character> stack = new Stack<Character>();
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == L_PAREN)
                stack.push(L_PAREN);
            else if (s.charAt(i) == L_BRACE)
                stack.push(L_BRACE);
            else if (s.charAt(i) == L_BRACKET)
                stack.push(L_BRACKET);
            else if (s.charAt(i) == R_PAREN) {
                if (stack.pop() != L_PAREN)
                    return false;
            } else if (s.charAt(i) == R_BRACE) {
                if (stack.pop() != L_BRACE)
                    return false;
            } else if (s.charAt(i) == R_BRACKET) {
                if (stack.pop() != L_BRACKET)
                    return false;
            }
        }
        return stack.isEmpty();
    }


    public static void main(String[] args) {
        String st1 = "[()]{()}{}";
        String st2 = "({})[]";
        String st3 = "(){}";

        System.out.println(checkParen(st3));
    }

}

<file_sep>package com.javabk.khai;

import java.util.Arrays;

public class CongMang2Chieu {
    public static void main(String[] args) {
        int[][] arr1=new int[][]{{1,5,9},{3,6,4},{7,2,8}};
        int[][] arr2=new int[][]{{2,6,9},{1,7,3},{5,4,1}};
        int[][] arr=new int[3][3];

        System.out.println("Mang 1: ");
        for (int i=0;i<arr1.length;i++){
            System.out.println(Arrays.toString(arr1[i]));
        }
        System.out.println("Mang 2: ");
        for (int i=0;i<arr1.length;i++) {
            System.out.println(Arrays.toString(arr2[i]));
        }
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                arr[i][j] = arr1[i][j]+arr2[i][j];
            }
        }
        System.out.println("Cong 2 mang: ");
        for (int i =0;i<arr.length;i++) {
            System.out.println(Arrays.toString(arr[i]));
        }
    }
}
<file_sep>package com.ateach.pdf2.oop.abstraction.quizz;


abstract class Hinh {
}

abstract class DaGiac extends Hinh {
}

class Tron extends Hinh {
}

class TamGiac extends DaGiac {
}

class ChuNhat extends DaGiac {
}

class Test2 {
    public static void main(String[] args) {
        Hinh h1 = new Tron();
        Hinh h2 = new TamGiac();
        Hinh h3 = new ChuNhat();
        DaGiac h4 = (DaGiac) h2;
        Tron h6 = (Tron) h1;
        h2 = h3;
        Hinh h5 = h1;
    }
}

<file_sep>package com.javabk.dao;

import java.util.Scanner;

public class DienTichHinh {
    public static void dienTinhHinhTron(){
        System.out.println("Tinh dien tich va chu vi hinh tron");
        Float r;
        Scanner sc = new Scanner(System.in);
        do {
            System.out.println("Nhap ban kinh");
            r = sc.nextFloat();
        }
        while (r<0);
        Float Dientich = ((314*r*r)/100);
        System.out.println("Dien tich hinh tron la:" + Dientich);

        Float d;
        do {
            System.out.println("Nhap duong kinh");
            d = sc.nextFloat();
        }
        while (d<0);
        Float Chuvi = ((314*d)/100);
        System.out.println("Chu vi hinh tron la:" + Chuvi);
    }
}
<file_sep>package com.ateach.designpattern.stragety;

public class Speak implements QuackBehavior{
    @Override
    public void quack() {
        System.out.println("Speak...");
    }
}
<file_sep>package com.ateach.pdf1.quizz.reviewPf1;

public class RotateArray {

    int[][] rotateImage(int[][] a) {
        int[][] rotate = new int[a.length][a.length];
        int index = 0;
        for (int i = a.length - 1; i >= 0; i--) {
            for (int j = 0; j < a.length; j++) {
                rotate[j][index] = a[i][j];
            }
            index++;
        }
        return rotate;
    }
}
<file_sep>package com.javabk.khai;

import java.util.Scanner;

public class ChenPhanTuVaoMang {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int[] array = new int[10];
        int[] array2 =  new int[11];
        int x,index,a;

        System.out.println("Nhap gia tri mang");
        for (int i = 0; i < array.length; i++){
            array[i] = sc.nextInt();
        }
        System.out.println("Nhap so can chen :");
        x = sc.nextInt();

        System.out.println("Nhap vi tri can chen:");
        index = sc.nextInt();

        for (int i = 0; i < array.length; i++){
            array2[i] = array[i];
        }

            if (index <= -1 || index >= array.length-1){
                System.out.println("Khong the chen duoc phan tu vao mang");
            }
            else {
                for(int i = index; i < array2.length; i++) {
                    if (i == array2.length-1){
                        array2[i] = x;
                        break;
                    }
                    a = array2[i];
                    array2[i] = x;
                    x = a;
                }
            for (int i = 0; i < array2.length; i++){
                    System.out.println(array2[i]);
        }

        }
    }
}
<file_sep>package com.ateach.pdf1.quizz.reviewPf1;

public class isLucky {
    boolean isLucky(int n) {
        String num = Integer.toString(n); //1234 -?"1234"
        int x = 0;
        int sum1 = 0;
        int sum2 = 0;

        if(num.length()%2 == 0) {
            x = num.length()/2;
            for(int i=0; i<x ;i++) {
                sum1 += Character.getNumericValue(num.charAt(i));
            }
            for(int i=x; i<num.length() ;i++) {
                sum2 += Character.getNumericValue(num.charAt(i));
            }

            if (sum1 == sum2) {
                return true;
            }else {
                return false;
            }
        }
        return false;
    }
}
<file_sep>package com.ateach.pdf2.orderAgo;

public class SelectionSort {
    public static void sort(int[] array) {
        for (int i = 0; i < array.length; i++) {
            int max = array[i]; // Lưu phần tử lớn nhất
            int index = i; // lưu vị trí chứa phần tử lớn nhất
            for (int j = i + 1; j < array.length; j++) {
                if(max < array[j]){
                    max = array[j];
                    index = j;
                }
            }
            // Nếu chỉ số đã thay đổi, ta sẽ hoán vị
            if(index != i){
                int temp = array[i];
                array[i] = array[index];
                array[index] = temp;
            }
        }

    }

}
<file_sep>package com.ateach.pdf2.collectionFrameWork.arraylinkedlist;

import java.util.ArrayList;
import java.util.Stack;

public class MergeList {

    public static void main(String[] args) {
        ArrayList<Integer> l1 = new ArrayList<Integer>();
        l1.add(3);
        l1.add(4);
        l1.add(5);
        ArrayList<Integer> l2 = new ArrayList<Integer>();
        l2.add(3);
        l2.add(4);
        l2.add(5);
        ArrayList<Integer> lnew = new ArrayList<Integer>();
        lnew.addAll(l1);
        lnew.addAll(l2);
        System.out.println(lnew.toString());
        Stack<Integer> stack = new Stack<Integer>();

    }
}

<file_sep>package com.ateach.medium;

public class KhachHang {
    static public int id;
    public String hoTen;
    int soDienThoai;
    public void show(){
        System.out.println(soDienThoai);
    }
}

class QuanLy{
    public static void main(String[] args) {
        KhachHang obj = new KhachHang();
        System.out.println(obj.hoTen);
        System.out.println(obj.soDienThoai);
    }
}

<file_sep>package com.javabk.ha;

import java.util.Scanner;

public class TimUoc {
    public static void UCLN(){
        int a;
        int b;
        Scanner scanner = new Scanner(System.in);
        System.out.println(" Nhập vào số a");
        a = scanner.nextInt();
        System.out.println("Nhập vào số b");
        b= scanner.nextInt();
        a = Math.abs(a);
        b = Math.abs(b);
        if(a==0 || b==0)
        {
            System.out.println(" no greatest common factor");
            System.out.println("Done !");
        }
        while ( a!= b)
        {
            if(a>b)
            {
                a=a-b;
            }
            else
            {
                b=b-a;
            }
        }
        System.out.println(" Greatest common factor: " + a );
    }
}
<file_sep>package com.ateach.pdf2.oop.exercise;

abstract class Quiz3 {

    public void methodNonAbstract() {
        System.out.println("This is method non Abstract");
    }

    abstract void methodAbstract();

}


abstract class Quiz4 {
    final int id = 100;
    static String name;
    String address;

    protected void methodProtected() {

    }

    private void methodPrivate() {

    }

    public void methodPublic() {

    }

}

//class testInheritanceQ3Q4 extends Quiz3,Quiz4 {
class testInheritanceQ3Q4 extends Quiz3 {
    void methodAbstract() {
        System.out.println("this's content");
    }

}<file_sep>package com.javabk.han;

public class CircleOfNumber {

    public static void main(String[] args) {
       circleOfNumber(10,2);

    }
    public static int circleOfNumber(int n,int firstNumber){
        int ketqua;
        if ((firstNumber + (n / 2)) > n) {
            ketqua = firstNumber + (n / 2);
        } else {
            ketqua = (firstNumber + (n / 2)) % n;
        }
        System.out.println(ketqua);
        return ketqua;
    }
}


<file_sep>package com.ateach.pdf2.oop.student;

public class StudentManagerTest {
    public static void main(String[] args) {
        StudentManager studentManager = new StudentManager();
        studentManager.displayAll();

        Student andy = new Student("Andy", 23);
        studentManager.add(andy);
        System.out.println("added " + andy.getInfomation());
        studentManager.displayAll();
        studentManager.find("Andy");
    }

}
<file_sep>package com.ateach.pdf2.oop.grocery;

public class ReadyMadeCake extends Cake {
    private final String[] SUPPORTED_DISCOUNT_CONDITIONS = {"Condition"};

    public int quantity;
    public ReadyMadeCake(String name, double rate,int quantity) {
        super(name, rate);
        this.quantity = quantity;
    }
    public ReadyMadeCake(Cake cake){
        super(cake);
        if (cake instanceof ReadyMadeCake) {
            this.quantity = ((ReadyMadeCake) cake).quantity;
        }
    }
    public double calcPrice () {
        return rate * quantity;
    }

    @Override public double getPrice() {
        return calcPrice();
    }

    @Override public double getDiscount(DiscountCondition[] discountConditions) {
        double discountAmount = 0;

        if(quantity > 5){
            discountAmount += DISCOUNT_IN_PERCENT/100*this.getPrice();
        }
        //We should not check the discount condition if it is empty
        if(discountConditions == null || discountConditions.length ==0 ){
            return discountAmount;
        }
        for (DiscountCondition discountCondition : discountConditions) {
            if(supportDiscountCondition(discountCondition)){
                /**
                 * We are at ReadyMadeCake class, we know how to calculate the discount for these items
                 */

                if(discountCondition instanceof Condition){
                    Condition nameOfCustomerCondition = (Condition) discountCondition;
                    if(nameOfCustomerCondition.willGetDiscount()){
                        discountAmount += nameOfCustomerCondition.getDiscountAmount();
                    }
                }

            }
        }
        return discountAmount;
    }

    @Override public String getInfo() {
        return toString() + ", price: " + getPrice();
    }

    @Override public boolean supportDiscountCondition(DiscountCondition discountCondition) {
        for (String supported_discount_condition : SUPPORTED_DISCOUNT_CONDITIONS) {
            if( supported_discount_condition.equals(discountCondition.getNameOfCondition())){
                return true;
            }
        }
        return false;
    }

    public String toString () {
        return super.toString() + "\t" + quantity +" (eggs)";
    }
}<file_sep># JavaCoreBK
JavaCore
<file_sep>package com.ateach.pdf2.oop.random;

import java.util.Random;

public class RandomOop {
    public  int seed;
    public RandomOop(int seeds) {
        this.seed = seeds;
    }

    public void getRandomValue(){
        Random random1 = new Random(this.seed);
        for (int i = 0; i < 50; i++) {
            System.out.print(random1.nextInt(100) + " ");
        }
    }
}
<file_sep>package com.ateach.pdf2.oop.exercise;

//a....
abstract  class AbClss1{
    abstract void method1();
    abstract void method2();
}
abstract  class AbClss2 extends AbClss1{
    abstract void method3();
    abstract void method4();
}

//public class Quiz6 extends AbClss{
//
//}

//b...
 class AbChild extends AbClss2{
    void method1() {
        System.out.println("Contents of method2");
    }
    void method2() {
        System.out.println("Contents of method2");
    }

    void method3() {
        System.out.println("Contents of method2");
    }
    void method4() {
        System.out.println("Contents of method2");
    }

}

<file_sep>package com.ateach.pdf1.basic.array2D;

import java.util.Scanner;

public class ThaoTacVoiArray2D {
    public static void array2D(){
        // gan truc tiep
        int[][] rating = new int [][]{{8,9,7,10},{8,7,7,10},{9,5,7,10}};
        Scanner scn = new Scanner(System.in);
        // gan gian tiep
        int[][] assignValue = new int[3][4];
        for (int i=0; i<assignValue.length;i++){
            for(int j=0;j<assignValue[i].length;j++){
                System.out.println("Gia tri dong: "+i+" cot:"+j);
                assignValue[i][j] = scn.nextInt();
            }
        }
        System.out.println("mang in ra: ");
        for (int i=0; i<3; i++){
            for(int j=0; j<4; j++){
                System.out.print(assignValue[i][j]+ " ");
            }
            System.out.println();
        }
        int sum= 0;
        for(int j=0; j<assignValue.length; j++){
            sum = sum + assignValue[j][3];
        }
        System.out.println("gia tri:"+sum);
        double trungBinh = sum/3;
        System.out.println(trungBinh);

    }


    public static void inMang(int arrs[][]){
        System.out.println("mang in ra: ");
        for (int i=0; i<arrs.length; i++){
            for(int j=0; j<arrs[i].length; j++){
                System.out.print(arrs[i][j]+ " ");
            }
            System.out.println();
        }
    }

    public static void duongCheoThuNhat(){
        int[][] arrgs = new int[][]{{1,2,4},{5,6,8},{9,6,3}};
        int sum = 0;
        // cach 1
        for(int i = 0; i<arrgs.length;i++){
            for(int j=0; j<arrgs[i].length; j++){
                if(i==j){
                    sum =sum+arrgs[i][j];
                }
            }
        }

        //cach 2
//        for(int i = 0; i<arrgs.length;i++){
//            sum = sum + arrgs[i][i];
//        }
        System.out.println("tong duong cheo 1: "+sum);
    }

    public static void duongCheoThuHai(){
        int[][] arr2d = new int[][]{{1,2,4},{5,6,8},{9,6,3}};
        int sum1 = 0;
        for(int k = 0; k < arr2d.length; k++){
            sum1 = sum1 + arr2d[k][arr2d.length-k-1]; // vi du k = 0 thi hang 0 cot 3(arr2d.length = 3)-0(k=0)-1  ->arr[0][2] + arr[1][1]+ arr[2][0]
        }
        System.out.println("Tong duong cheo 2: "+sum1);
    }

    // cach 2 tinh tong 2 duong cheo

    public static void tongHaiDuongCheo(){
        int[][] arr2d = new int[][]{{1,2,4},{5,6,8},{9,6,3}};
        int sum = 0;
        for (int i = 0; i<arr2d.length; i++){
            sum = sum + arr2d[i][i]+arr2d[i][arr2d.length-i-1];
        }
        System.out.println(" tong hai duong cheo: "+sum);
    }

    public static void congHaiMaTran (){
        int [][] maTran1 = new int[][]{{2,3,4},{1,1,1},{6,5,2}};
        int [][] maTran2 = new int[][]{{1,6,7},{3,4,6},{2,3,2}};
        int [][] maTran3 = new int[3][3];
        for(int i = 0; i<maTran1.length; i++){
            for(int j = 0; j<maTran1[i].length; j++){
                maTran3[i][j] = maTran1[i][j] + maTran2[i][j];
            }
        }
        inMang(maTran3);
    }
}
<file_sep>package com.ateach.pdf2.collectionFrameWork.hashandtree;

import java.util.HashMap;
import java.util.Map;

public class HashMapTest {

    static void insertAndPrint(HashMap<Integer, String> map)
    {
        int[] array= {1, -1, 0, 2,-2};
        for (int x: array)
        {
            map.put(x, Integer.toString(x));
        }
        for (int k: map.keySet())
        {
            System.out.print(k + ", ");
        }
    }

    // Driver method to test above method
    public static void main (String[] args)
    {
        HashMap<String,String> map1 = new HashMap<String,String>();

        map1.put("a","Anchor");
        map1.put("b","Anchor");
        map1.put(null,"value null");
//        map1.put("b","value null");
        for (Map.Entry x: map1.entrySet()){
            System.out.println("key:   " +x.getKey()+"   value:  "+x.getValue());

        }
//        HashMap<Integer, String> map = new HashMap<Integer, String>();
//        insertAndPrint(map);
    }
}
<file_sep>//package com.ateach.pdf2.oop.abstraction.example1;
//
//// <NAME>
//public class Boss extends Employee {
//
//    private int workingHours;
//
//    public Boss(String name, int paymentPerHour, int workingHours) {
//        super(name, paymentPerHour);
//        this.workingHours = workingHours;
//    }
//
//
//    public int calculateSalaryBossCuaThu() {
//        return getPaymentPerHour() * workingHours;
//    }
//}<file_sep>package com.javabk.khai;

import java.util.Scanner;

public class GopHaiMang {

    public static void main(String[] args) {
        int[] array1 = new int[5];
        int[] array2 = new int[5];
        Scanner sc = new Scanner(System.in);

        System.out.println("Nhap gai tri cho mang 1 :");
        for (int i = 0; i<array1.length; i++){
            array1[i] = sc.nextInt();
        }

        System.out.println("Nhap gai tri cho mang 2 :");
        for (int i = 0; i<array1.length; i++){
            array2[i] = sc.nextInt();
        }
        int[] array3 = new int[array1.length + array2.length];

        System.out.println("Gia tri cua mang 3 :");
        for (int i = 0; i<array3.length; i++){
            if(i < array1.length) {
                array3[i] = array1[i];
            }
            else {
                if (i >= array1.length){
                    array3[i] = array2[i - array1.length];
                }
            }
            System.out.print(array3[i]+"\t");
        }

    }
}
<file_sep>package com;

class Cha {

    private String khoVang = "";

    Cha(String khoVang) {
        System.out.println("dsfdsfdfdsf");
        this.khoVang = khoVang;
    }

    private   void display(){
        System.out.println(khoVang );
    }

}



<file_sep>package com.ateach.pdf2.fileInputStream;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
public class FileInputStreamExample {
    public static void main(String[] args) {
        File file=new File("file.txt");
        try {
            FileInputStream fileInputStream=new FileInputStream(file);
            int b;
            while((b=fileInputStream.read())!=-1){
                System.out.print((char)b);
            }
            fileInputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
<file_sep>package com.ateach.pdf1.basic.array2D;

import java.util.Scanner;

public class BanCo {
    public static void duongDiQuanXe() {

        String[] chieuNgang = {"a", "b", "c", "d", "e", "f", "g", "h"};
        String[] chieuDoc = {"1", "2", "3", "4", "5", "6", "7", "8"};
        String[][] banCoMoi = new String[8][8];

        for (int i = 0; i < chieuNgang.length; i++) {
            for (int j = chieuDoc.length - 1; j >= 0; j--) {
                String giaTri = chieuNgang[i] + "" + chieuDoc[j];
                banCoMoi[i][j] = giaTri;
            }
        }
        inMang(banCoMoi);

        System.out.println(" Nhap vi tri cua quan xe: ");
        Scanner scn = new Scanner(System.in);
        String viTriXe = scn.next();
        int soViTri = Integer.parseInt(viTriXe.substring(0, 1));
        System.out.println(soViTri);

        //duyet qua cot
        for (int i = 0; i < banCoMoi.length; i++) {
            System.out.print(banCoMoi[i][soViTri - 1] + " ");

        }
        //duyet qua dong
        for (int i = 0; i < banCoMoi.length; i++) {
            System.out.print(banCoMoi[soViTri - 1][i] + " ");
        }
    }

    public static void inMang(String arrs[][]) {
        System.out.println("mang in ra: ");
        for (int i = 0; i < arrs.length; i++) {
            for (int j = 0; j < arrs[i].length; j++) {
                System.out.print(arrs[i][j] + " ");
            }
            System.out.println();
        }
    }
}
<file_sep>package com.ateach.pdf2.oop.account;

import java.text.SimpleDateFormat;
import java.util.Date;

class AccountTest {

    public static void main(String[] args) {
        SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
        Date date = new Date();
        Account ac = new Account();
        ac.setId(111);
        ac.setBalance(20);
        ac.setDateCreated(date);
        ac.setAnnualInterestRate(4.5); // lai suat 1 nam 4.5$
        ac.withdraw(2.5); // rut 2.5$
        ac.deposit(3); // them vao 3$

        System.out.println("Account id: "+ac.getId());
        System.out.println("Date create account: " + formatter.format(ac.getDateCreated()));
        System.out.println("Balance: " + ac.getBalance());
        System.out.println("Monthly Interest Rate: " + ac.getMonthlyInterestRate());
    }
}<file_sep>package com.javabk.liem;

import java.util.Random;
import java.util.Scanner;

public class LenhDieuKien {
    public static void cauLenhDieuKien(){
        System.out.println("Hello World!");
        Scanner sc = new Scanner(System.in);
        int Count,Count2,SoTron ;
        double Sprtt = Math.sqrt(100);
        SoTron = (int)(Sprtt);
        boolean IS;
        int[] SoNguyenTo;
        int CountArray = 0;
        for (Count=2;Count<=100;Count++) {
            //System.out.println("");
            IS = true;
            Sprtt = Math.sqrt(Count);
            SoTron = (int) (Sprtt);
            for (Count2 = 2; Count2 < Count; Count2++) {
                if (Count % Count2 == 0) {
                    IS = false;
                    break;
                }
            }
            if (IS == true) {
                System.out.println("Số " + Count + " là số nguyên tố");
            }
        }
    }

    public static void xoSo(){
        Scanner sc = new Scanner(System.in);
        int So_nhap_vao;
        do {
            System.out.print("Vui lòng nhập số có 2 chữ số : ");
            So_nhap_vao = sc.nextByte();
        } while ((So_nhap_vao<0)||(So_nhap_vao>100));
        Random rd = new Random();
        int na = 100;
        int rds = rd.nextInt(na);
        System.out.println("Số Random là : " + rds);
        int So_nhap_vao_thu_nhat_la = So_nhap_vao / 10;
        int So_nhap_vao_thu_hai_la = So_nhap_vao % 10;
        int So_rds_thu_nhat_la = rds / 10;
        int So_rds_thu_hai_la = rds % 10;
        if ((So_nhap_vao_thu_nhat_la == So_rds_thu_nhat_la) && (So_nhap_vao_thu_hai_la == So_rds_thu_hai_la)){
            System.out.println("Phần thưởng của bạn là 10 000$");
        }
        else if ((So_nhap_vao_thu_nhat_la == So_rds_thu_hai_la) && (So_rds_thu_nhat_la == So_nhap_vao_thu_hai_la)){
            System.out.println("Phần thưởng của bạn là 3000$");
        }
        else if ((So_nhap_vao_thu_nhat_la == So_rds_thu_nhat_la) || (So_nhap_vao_thu_hai_la == So_rds_thu_hai_la)||
                (So_nhap_vao_thu_nhat_la == So_rds_thu_hai_la) || (So_rds_thu_nhat_la == So_nhap_vao_thu_hai_la)){
            System.out.println("Phần thưởng của bạn là 1000$");
        }
        else {
            System.out.println("Phần thưởng của bạn là 0$. Chúc mừng bạn");
        }
    }
    public static void giaiPhuongTrinh(){
        Scanner sc = new Scanner(System.in);
        System.out.println("Vui lòng nhập lần lượt 3 hệ số a, b, c");
        System.out.print("Vui lòng nhập số  A : ");
        float a = sc.nextFloat();
        System.out.print("Vui lòng nhập số  B : ");
        float b = sc.nextFloat();
        System.out.print("Vui lòng nhập số  C : ");
        float c = sc.nextFloat();
        float  Nghiem1;
        if(a == 0){
            if(b == 0 &&(c!=0)){
                System.out.println("Phương trình vô nghiệm");
            }
            else if((b!=0)&&(c!=0) ){
                Nghiem1 = -b/c;
                System.out.print("Phương Trình Có 1 nghiệm là : " + Nghiem1);
            }
            else if(( b == 0 )&&(c==0) ){
                System.out.println("Phương trình có vô số nghiệm");
            }
        }
        else {
            float Delta= b*b - 4*a*c;
            if (Delta < 0){
                System.out.println("Phương trình Vô nghiệm");
            }
            else if(Delta == 0 ){
                System.out.println("Phương trình có nghiệm kép : " + -b/(2*a));
            }
            else if(Delta > 0 ){
                double Can_2_cua_delta = Math.sqrt(Delta);
                double Nghiem_1 = (-b + Can_2_cua_delta)/(2*a);
                double Nghiem_2 = (-b - Can_2_cua_delta)/(2*a);
                System.out.println("Phương trình có 2 nghiệm lần lượt là : " + Nghiem_1 + " , " + Nghiem_2);
            }
        }
    }
}
<file_sep>package com.ateach.pdf1.basic.TDD;

public class Calculator {
    public int add(int x, int y) {
        //  throw  new UnsupportedOperationException("not support operation");
        return x - y;
    }
    public int sub(int x, int y){
        return x - y;
    }
}
<file_sep>package com.javabk.ha;

import java.util.Scanner;

public class GopMang {
    public static void gopMang(){
        Scanner scn = new Scanner(System.in);
        int i,j;
        int m,n;
        int[] arrayA = new int[100];
        int[] arrayB = new int[100];
        int[] arrayC = new int[arrayA.length+arrayB.length];
        for(i=0;i<arrayA.length;i++){

        }

    }
}
<file_sep>package com.ateach.pdf1.basic.array;

public class ContructArray {
    int[] constructArray(int size) {
        int[] arr = new int[size];
        arr[0] = 1;
        arr[1] = 7;
        for(int i = 2; i< size-1;i++){
            arr[i] = i ;
            arr[i+1] = (size) -1;

        }
        return arr;
    }
}
<file_sep>package com.ateach.pdf2.oop.accessexample.publicaccess;

public class PublicAcess {

    // access every where. every package. it open for all
}
<file_sep>package com.ateach.pdf2.oop.polymorphism.example1;

/**
 * This represents payment interface
 */
interface Payment {
    public void pay();
}<file_sep>package com.ateach.pdf2.collectionFrameWork.stackandqueu;

import java.util.LinkedList;
import java.util.Queue;

public class Queus {
    public static void main(String[] args) {
        Queue<Integer> q = new LinkedList<>();

        q.add(1);
        q.add(2);
        q.add(3);
        for (Integer i : q) {
            System.out.println(i);
        }

        System.out.println("peek method: " + q.peek()); //Lấy phần tử ở đầu tiên hàng đợi nhưng không xóa
        System.out.println("poll method: " + q.poll());//Lấy phần từ đầu tiên của hàng đợi và xóa nó ra khỏi hàng đợi
        for (Integer i : q) {
            System.out.println(i);
        }
//        System.out.println();

    }
}
<file_sep>package com.ateach.pdf2.oop.accessexample.protectedaccess;

public class ProtectedAcess {

    // we will come back in lesson inheritance
}
<file_sep>package com.ateach.pdf2.orderAgo;

public class OrderTree {
    int[] sortByHeight(int[] a) {
        for(int i = 0; i < a.length - 1; i++){
            if(a[i] != -1){
                int smallest = i;
                for(int j = i + 1; j < a.length; j++){
                    if(a[j] != -1){
                        if(a[smallest] > a[j]){
                            smallest = j;
                        }
                    }
                }
                int temp = a[smallest];
                a[smallest] = a[i];
                a[i] = temp;
            }
        }
        return a;
    }
}
<file_sep>package com.ateach.pdf2.oop.exercise;

public class Quiz2 {
    static String name = "<NAME>";
    String address = "Codegym Da nang";
}

class Test{

    public static void main(String[] args) {
        // access static field

        // access non-static filed
    }
}<file_sep>package com.ateach.pdf1.basic.method;

public class ThamBienThamTri {

    public  static void goiHam(){
//        int giaTriGoc = 10;
//        truyenThamTri(giaTriGoc);
//        System.out.println("Gia tri sau khi goi: "+ giaTriGoc);

        int [] mangGoc = {400,500};
        System.out.println("Gia tri ban dau: " + mangGoc[0] + " " +mangGoc[1]);
        truyenThamChieu(mangGoc);
        System.out.println("Gia tri sau khi goi ham: "+ mangGoc[0] + "  "+ mangGoc[1]);
    }

    static void truyenThamTri(int bien)
    {
        bien = 20;
    }

    static void truyenThamChieu(int mang[]){
        mang[0] = 200;
        mang[1] = 100;
    }
}
<file_sep>package com.ateach.pdf2.oop.inheritance.person;

import java.util.Scanner;

public class Student extends Person{
   private String program;
   private int year;
   private double fee;

    public String getProgram() {
        return program;
    }

    public void setProgram(String program) {
        this.program = program;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    public double getFee() {
        return fee;
    }

    public void setFee(double fee) {
        this.fee = fee;
    }

    public Student(){
        super();
        program = "";
        year = 0;
        fee = 0.0;

    }

    public Student(String name, String address, String program, int year, double fee) {
        super(name,address);
        this.program = program;
        this.year = year;
        this.fee = fee;
    }

    public void addInfoStudent(){
        super.addInfo();
        Scanner sc = new Scanner(System.in);
        System.out.println("Enter program: ");
        program = sc.next();
        System.out.println("Enter year(int): ");
        year = sc.nextInt();
        System.out.println("Enter fee (double): ");
        fee = sc.nextDouble();
    }
    public String toString(){
        return "Student info: "+super.toString()+", program: "+program+ ", year: "+year + ", fee: "+fee +"";
    }
}
<file_sep>package com.ateach.pdf2.oop.onlyabstract.animal;

public class Tiger extends Animal {
    @Override
    public String makeSound() {
        return "Tiger: roarrrrr!";
    }
    public String howToEat() {
        return "could be fried";
    } // tiger khong can co phuong thuc nay, nhung vi abstrac nen phai khai bao
}
