diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 13566b8..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 639900d..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 0e0500a..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Java/1.10.java b/Java/1.10.java new file mode 100644 index 0000000..142a762 --- /dev/null +++ b/Java/1.10.java @@ -0,0 +1,81 @@ +// EX 1.10 Write a program to get next day of a given date +// Write a program to get next day of a given date. + +// Please don't use any library of Java. + +// Test data 1 +// Input: 2020, 02, 29 +// Output: 2020, 03, 01 +import java.util.Scanner; +public class Main { + public static void main(String[] Strings) { + Scanner scanner = new Scanner(System.in); + String string = scanner.nextLine(); + var year = string.substring(0,4); + int nam = Integer.parseInt(year); + var month = string.substring(6,8); + int thang = Integer.parseInt(month); + var day = string.substring(10,12); + int ngay = Integer.parseInt(day); + boolean nhuan = true; + int i; + if (nam % 400 == 0) { + nhuan = true; + } + else if (nam % 100 == 0) { + nhuan = false; + } + else if (nam % 4 == 0) { + nhuan = true; + } + else { + nhuan = false; + } + + if (thang == 1 || thang == 3 || thang == 5 || thang == 7 || thang == 8 || thang == 10 || thang == 12) { + i = 31; + } + else if (thang == 2) { + if (nhuan) { + i = 29; + } + else { + i = 28; + } + } + else { + i = 30; + } + + if (ngay < i) { + ngay = ngay + 1; + } + else { + ngay = 1; + if (thang == 12) { + thang = 1; + nam = nam + 1; + } + else { + thang = thang + 1; + } + } + System.out.print(nam); + System.out.print(", "); + if (thang < 10) { + System.out.print("0"); + System.out.print(thang); + } + else { + System.out.print(thang); + } + System.out.print(", "); + if (ngay < 10) { + System.out.print("0"); + System.out.print(ngay); + } + else { + System.out.print(ngay); + } + } +} diff --git a/Java/1.2.java b/Java/1.2.java new file mode 100644 index 0000000..cd849f0 --- /dev/null +++ b/Java/1.2.java @@ -0,0 +1,26 @@ +// EX 1.2 Write a program that takes a year from the user and print whether that year is a leap year or not. +// Write a program that takes a year from the user and print whether that year is a leap year or not. +// Test Data + +// Input the year: 2016 + +// Expected Output : True +import java.util.Scanner; + +public class Main { + + public static void main(String[] args) { + try (Scanner scanner = new Scanner(System.in)) { + int year = scanner.nextInt(); + if ( year % 4 == 0 && year % 100 != 0) { + System.out.print("True"); + } + else if ( year % 400 == 0) { + System.out.print("True"); + } + else { + System.out.print("False"); + } + } + } +} diff --git a/oop_employee_management/.idea/sonarlint/issuestore/index.pb b/Java/1.3.java similarity index 100% rename from oop_employee_management/.idea/sonarlint/issuestore/index.pb rename to Java/1.3.java diff --git a/Java/1.4.java b/Java/1.4.java new file mode 100644 index 0000000..9bdc8d6 --- /dev/null +++ b/Java/1.4.java @@ -0,0 +1,65 @@ +// EX 1.4. Write a program which reads a sequence of integers and prints how often each number of this sequence occurs. +// Write a program which reads a sequence of integers and prints how often each number of this sequence occurs. + +// Example + +// Input: + +// 9 + +// 1 3 5 7 5 3 7 2 5 + +// Output: + +// 1(1), 3(2), 5(3), 7(2), 2(1) + + + +// Please note that: + +// 9 as array size + +// 1 3 5 7 5 3 7 2 5 as array +import java.util.Scanner; + +public class Main { + + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + int a = scanner.nextInt(); + int[] arr = new int[a]; + for (int i = 0; i < a; i++) { + arr[i] = scanner.nextInt(); + } + + boolean check = true; + boolean first = true; + for (int i = 0; i < arr.length; i++) { + check = true; + for (int j = 0; j < i; j++) { + if (arr[i] == arr[j]) { + check = false; + break; + } + } + + if (check == true) { + int sum = 1; + for (int j = i + 1; j < arr.length; j++) { + if (arr[j] == arr[i]) { + sum++; + } + } + if (first == true) { + System.out.print(arr[i] + "(" + sum + ")"); + first = false; + } else { + System.out.print(", " + arr[i] + "(" + sum + ")"); + } + + } + } + + } +} + diff --git a/Java/1.5.java b/Java/1.5.java new file mode 100644 index 0000000..1108056 --- /dev/null +++ b/Java/1.5.java @@ -0,0 +1,41 @@ +// EX 1.5. Write a program that accept an integer (n) from the user and outputs combinations that express n as a sum of two prime numbers. +// Write a program that accept an integer (n) from the user and outputs combinations that express n as a sum of two prime numbers. + +// Example + +// Input: 10 + +// Output: 7+3, 5+5 +import java.util.Scanner; + +public class Main { + private static boolean isPrime(int a) { + if ( a < 2) { + return false; + } + for ( int i = 2; i < a; i++) { + if ( a % i == 0) { + return false; + } + } + return true; + } + + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + int a = scanner.nextInt(); + boolean first = true; + for (int i = a -2; i >= a /2; i--) { + if ( isPrime(i) && isPrime(a-i)) { + if ( first == true) { + first = false; + System.out.print( i + "+" + (a - i)); + } + else { + System.out.print( ", " + i + "+" + (a - i)); + } + } + } + } +} + diff --git a/Java/1.6.java b/Java/1.6.java new file mode 100644 index 0000000..15c1f63 --- /dev/null +++ b/Java/1.6.java @@ -0,0 +1,44 @@ +// EX 1.6 Write a program to check whether the sequence of numbers 1, 2, 3 appears in a given array of integers somewhere. +// Write a program to check whether the sequence of numbers 1, 2, 3 appears in a given array of integers somewhere. + +// Example +// Input: +// 5 +// 1 1 2 3 1 +// Output: 1 +// Please note that: +// 5 as array size +// 1 1 2 3 1 as array + +import java.util.Scanner; + +/** + * array2 + */ +public class Main { + public static boolean test(int[] a) { + for (int i = 0; i < a.length-2 ; i++) { + if (a[i] == 1 && a[i + 1] == 2 && a[i + i] == 3) { + return true; + } + } + return false; + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int[] a = new int[n]; + for (int i = 0; i < n; i++) { + a[i] = sc.nextInt(); + } + if (test(a)) { + System.out.print(0); + } else { + System.out.print(1); + } + } +} + + + diff --git a/Java/1.7.java b/Java/1.7.java new file mode 100644 index 0000000..bfef6cd --- /dev/null +++ b/Java/1.7.java @@ -0,0 +1,56 @@ +// EX 1.7 If a number appears three times in a row in an array it is called a triple. Write a program to check if a triple is presents in an array of integers or not. +// If a value appears three times in a row in an array it is called a triple. Write a program to check if a triple is presents in an array of integers or not. + +// Example +// Input: +// 7 +// 1 1 1 2 2 2 1 +// Output: +// 1 + +// Please note that: + +// 7 as array size +// 1 1 1 2 2 2 1 as array +import java.util.Scanner; + +/** + * array2 + */ +public class Main{ + public static boolean test(int[] a, int n) { + for (int i = 0; i < n-1; i++) { + if (a[i] == a[i + 1] && a[i] == a[i + 2] && a[i + 1] == a[i + 2]) { + { + return true; + } + } + } + return false; + +} + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int[] a = new int[n]; + for (int i = 0; i < n; i++) { + a[i] = sc.nextInt(); + } + + if (test(a, n) == true) { + System.out.print(1); + } else { + System.out.print(0); + } + // for (int i = 0; i < a.length; i++) { + // System.out.print(a[i] + " "); + // } + } +} + + + + + + + diff --git a/Java/1.8.java b/Java/1.8.java new file mode 100644 index 0000000..53dcec5 --- /dev/null +++ b/Java/1.8.java @@ -0,0 +1,52 @@ +// EX 1.8 Write a program to find k largest even number in an array +// Write a program to find k largest even number in an array with size of n. + +// Example +// Input: +// 2 +// 8 +// 4 5 9 12 9 22 45 7 +// Output: +// 22 12 +// Please note that: +// 2 as k +// 8 as n +// 4 5 9 12 9 22 45 7 as array + +import java.util.PriorityQueue; +import java.util.Scanner; + +class GFG { + + static void kLargest(int a[], int l, int k) { + PriorityQueue pq = new PriorityQueue(); + + for (int i = 0; i < l; i++) { + if (a[i] % 2 == 0) { + pq.add(a[i]); + if (pq.size() > k) { + pq.poll(); + } + } + } + while (!pq.isEmpty()) { + System.out.print(pq.peek() + " "); + pq.poll(); + } + System.out.println(); + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int k = sc.nextInt(); + int n = sc.nextInt(); + int a[] = new int[n]; + int l = a.length; + for (int i = 0; i < n; i++) { + a[i] = sc.nextInt(); + } + kLargest(a, l, k); + + } +} + diff --git a/Java/1.9.java b/Java/1.9.java new file mode 100644 index 0000000..6b03b0d --- /dev/null +++ b/Java/1.9.java @@ -0,0 +1,57 @@ +// EX 1.9 Write a program to separate and sort even and odd numbers of an array of integers +// EX 2.8 Write a program to separate and sort even and odd numbers of an array of integers. +// Put all sorted odd numbers first, and then sorted even numbers. +// Example: +// Input: +// 9 +// 0 1 3 4 5 6 7 8 10 +// Output: +// 1 3 5 7 0 4 6 8 10 + +// Please note that: +// 9 as size of array +// 0 1 3 4 5 6 7 8 10 as array + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Scanner; + +public class Main { + + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + int n = scanner.nextInt(); + ArrayList oddNumbers = new ArrayList<>(); + ArrayList evenNumbers = new ArrayList<>(); + + for (int i = 0; i < n; i++) { + int temp = 0; + temp = scanner.nextInt(); + if (temp % 2 != 0) { + oddNumbers.add(temp); + } else { + evenNumbers.add(temp); + } + } + Collections.sort(oddNumbers); + Collections.sort(evenNumbers); + + ArrayList numbers = new ArrayList<>(); + for (Integer i : oddNumbers) { + numbers.add(i); + } + for (Integer i : evenNumbers) { + numbers.add(i); + } + boolean first = true; + for (Integer i : numbers) { + if (first) { + first = false; + System.out.print(i); + } else { + System.out.print(" " + i); + } + } + } +} + diff --git a/README.md b/README.md deleted file mode 100644 index d8e4fba..0000000 --- a/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Bài tập về OOP - -[shareprogramming.net](https://shareprogramming.net/) \ No newline at end of file diff --git a/exercise_oop_account/Account.java b/exercise_oop_account/Account.java deleted file mode 100644 index 96b3f83..0000000 --- a/exercise_oop_account/Account.java +++ /dev/null @@ -1,41 +0,0 @@ -public class Account { - private int id; - private String name; - private int balance; - - public Account(int id, String name, int balance) { - this.id = id; - this.name = name; - this.balance = balance; - } - - public String getName() { - return name; - } - - public int getBalance() { - return balance; - } - - public void credit(int amount) { - this.balance += amount; - } - - public void debit(int amount) { - if (amount > this.balance) { - System.out.println("Thanh Toan khong thanh cong"); - } else { - this.balance -= amount; - } - } - - public void tranferTo(Account account, int amount) { - if (amount > this.balance) { - System.out.println("Chuyen tien khong thanh cong"); - } else { - // Tru tien tai khoan chuyen - this.balance -= amount; - account.credit(amount); - } - } -} diff --git a/exercise_oop_account/Main.java b/exercise_oop_account/Main.java deleted file mode 100644 index 1c15ee1..0000000 --- a/exercise_oop_account/Main.java +++ /dev/null @@ -1,35 +0,0 @@ -public class Main { - - public static void main(String[] args) { - Account a = new Account(1, "A", 50); - Account b = new Account(1, "B", 10); - - System.out.println("Balance A: " + a.getBalance()); - System.out.println("Balance B: " + b.getBalance()); - System.out.println(); - - // Cong tien vao tai khoan - a.credit(30); - System.out.println("Balance A: " + a.getBalance()); - System.out.println("Balance B: " + b.getBalance()); - System.out.println(); - - // Tru tien vao tai khoan - a.debit(20); - System.out.println("Balance A: " + a.getBalance()); - System.out.println("Balance B: " + b.getBalance()); - System.out.println(); - - // Tru tien vao tai khoan khong hop le - a.debit(1000); - System.out.println("Balance A: " + a.getBalance()); - System.out.println("Balance B: " + b.getBalance()); - System.out.println(); - - // Chuyen tien cho b - a.tranferTo(b, 10); - System.out.println("Balance A: " + a.getBalance()); - System.out.println("Balance B: " + b.getBalance()); - System.out.println(); - } -} diff --git a/exercise_oop_composition_book_author/exercise_oop_composition_book_author.iml b/exercise_oop_composition_book_author/exercise_oop_composition_book_author.iml deleted file mode 100644 index c90834f..0000000 --- a/exercise_oop_composition_book_author/exercise_oop_composition_book_author.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/exercise_oop_composition_book_author/src/Author.java b/exercise_oop_composition_book_author/src/Author.java deleted file mode 100644 index 582797d..0000000 --- a/exercise_oop_composition_book_author/src/Author.java +++ /dev/null @@ -1,38 +0,0 @@ -public class Author { - private String name; - private String email; - private String gender; - private int age; - - public Author(String name, String email, String gender, int age) { - this.name = name; - this.email = email; - this.gender = gender; - this.age = age; - } - - public String getName() { - return name; - } - - public String getEmail() { - return email; - } - - public String getGender() { - return gender; - } - - public int getAge() { - return age; - } - - public String toString() { - return "Author{" + - "name='" + name + '\'' + - ", email='" + email + '\'' + - ", gender='" + gender + '\'' + - ", age=" + age + - '}'; - } -} diff --git a/exercise_oop_composition_book_author/src/Book.java b/exercise_oop_composition_book_author/src/Book.java deleted file mode 100644 index 8d3011a..0000000 --- a/exercise_oop_composition_book_author/src/Book.java +++ /dev/null @@ -1,39 +0,0 @@ - -public class Book { - private String name; - private Author author; - private double price; - private int count; - - public Book(String name, Author author, double price, int count) { - this.name = name; - this.author = author; - this.price = price; - this.count = count; - } - - public String getName() { - return name; - } - - public Author getAuthor() { - return author; - } - - public double getPrice() { - return price; - } - - public int count() { - return count; - } - - public String toString() { - return "Book{" + - "name='" + name + '\'' + - ", author=" + author.getName() + - ", price=" + price + - ", count=" + count + - '}'; - } -} diff --git a/exercise_oop_composition_book_author/src/Main.java b/exercise_oop_composition_book_author/src/Main.java deleted file mode 100644 index 27938f4..0000000 --- a/exercise_oop_composition_book_author/src/Main.java +++ /dev/null @@ -1,8 +0,0 @@ -public class Main { - - public static void main(String[] args) { - Author author = new Author("shareprogramming.net", "nthanhhai2909@gmail.com", "male", 23); - Book book = new Book("Java OOP", author, 10, 100); - System.out.println(book.toString()); - } -} diff --git a/exercise_oop_composition_student_address/exercise_oop_composition_student_address.iml b/exercise_oop_composition_student_address/exercise_oop_composition_student_address.iml deleted file mode 100644 index c90834f..0000000 --- a/exercise_oop_composition_student_address/exercise_oop_composition_student_address.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/exercise_oop_composition_student_address/src/Address.java b/exercise_oop_composition_student_address/src/Address.java deleted file mode 100644 index fe2232e..0000000 --- a/exercise_oop_composition_student_address/src/Address.java +++ /dev/null @@ -1,39 +0,0 @@ - -public class Address { - private String country; - private String city; - private String district; - private String street; - - public Address(String country, String city, String district, String street) { - this.country = country; - this.city = city; - this.district = district; - this.street = street; - } - - public String getCountry() { - return country; - } - - public String getCity() { - return city; - } - - public String getDistrict() { - return district; - } - - public String getStreet() { - return street; - } - - public String toString() { - return "Address{" + - "country='" + country + '\'' + - ", city='" + city + '\'' + - ", district='" + district + '\'' + - ", street='" + street + '\'' + - '}'; - } -} diff --git a/exercise_oop_composition_student_address/src/Main.java b/exercise_oop_composition_student_address/src/Main.java deleted file mode 100644 index 3b72307..0000000 --- a/exercise_oop_composition_student_address/src/Main.java +++ /dev/null @@ -1,13 +0,0 @@ -public class Main { - - public static void main(String[] args) { - Address address = new Address("VN", "HCM", "Q7", "428 LE VAN LUONG"); - Student student = new Student(); - student.setName("HGA"); - student.setAddress(address); - student.setAge(23); - student.setScore(5); - System.out.println(student.toString()); - System.out.println("Xep loai: " + student.getRating()); - } -} diff --git a/exercise_oop_composition_student_address/src/Student.java b/exercise_oop_composition_student_address/src/Student.java deleted file mode 100644 index b2059e3..0000000 --- a/exercise_oop_composition_student_address/src/Student.java +++ /dev/null @@ -1,58 +0,0 @@ - -public class Student { - private String name; - private int age; - private double score; - private Address address; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getAge() { - return age; - } - - public void setAge(int age) { - this.age = age; - } - - public double getScore() { - return score; - } - - public void setScore(double score) { - this.score = score; - } - - public Address getAddress() { - return address; - } - - public void setAddress(Address address) { - this.address = address; - } - - public String getRating() { - if (this.score < 5.0) { - return "bad"; - } else if (this.score >= 5.0 && this.score < 8.0) { - return "medium"; - } else { - return "good"; - } - } - - public String toString() { - return "Student{" + - "name='" + name + '\'' + - ", age=" + age + - ", score=" + score + - ", address=" + address.toString() + - '}'; - } -} diff --git a/exercise_oop_date/exercise_oop_date.iml b/exercise_oop_date/exercise_oop_date.iml deleted file mode 100644 index c90834f..0000000 --- a/exercise_oop_date/exercise_oop_date.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/exercise_oop_date/src/Date.java b/exercise_oop_date/src/Date.java deleted file mode 100644 index 5098c1b..0000000 --- a/exercise_oop_date/src/Date.java +++ /dev/null @@ -1,56 +0,0 @@ - -public class Date { - private int day; - private int month; - private int year; - - public Date(int day, int month, int year) { - this.day = day; - this.month = month; - this.year = year; - } - - public int getDay() { - return day; - } - - public void setDay(int day) { - this.day = day; - } - - public int getMonth() { - return month; - } - - public void setMonth(int month) { - this.month = month; - } - - public int getYear() { - return year; - } - - public void setYear(int year) { - this.year = year; - } - - public String toString() { - return "Date{" + - "day=" + day + - ", month=" + month + - ", year=" + year + - '}'; - } - - public boolean isLeapYear() { - if (this.year % 400 == 0) - return true; - - // Nếu số năm chia hết cho 4 và không chia hết cho 100, - // đó không là 1 năm nhuận - if (this.year % 4 == 0 && this.year % 100 != 0) - return true; - - return false; - } -} diff --git a/exercise_oop_date/src/Main.java b/exercise_oop_date/src/Main.java deleted file mode 100644 index 84e4055..0000000 --- a/exercise_oop_date/src/Main.java +++ /dev/null @@ -1,8 +0,0 @@ -public class Main { - - public static void main(String[] args) { - Date date = new Date(12, 3, 2016); - System.out.println(date.toString()); - System.out.println(date.isLeapYear()); - } -} diff --git a/exercise_oop_employee/exercise_oop_employee.iml b/exercise_oop_employee/exercise_oop_employee.iml deleted file mode 100644 index c90834f..0000000 --- a/exercise_oop_employee/exercise_oop_employee.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/exercise_oop_employee/src/Employee.java b/exercise_oop_employee/src/Employee.java deleted file mode 100644 index 33e82b3..0000000 --- a/exercise_oop_employee/src/Employee.java +++ /dev/null @@ -1,51 +0,0 @@ -public class Employee { - private int id; - private String lastName; - private String firstName; - private int salary; - - public Employee(int id, String lastName, String firstName, int salary) { - this.id = id; - this.lastName = lastName; - this.firstName = firstName; - this.salary = salary; - } - - public int getId() { - return id; - } - - public String getLastName() { - return lastName; - } - - public String getFirstName() { - return firstName; - } - - public int getSalary() { - return salary; - } - - public void setSalary(int salary) { - this.salary = salary; - } - - public String getFullName() { - return this.lastName + " " + this.firstName; - } - - public int getAnnualSalary() { - return this.salary * 12; - } - - public int upToSalary(int percent) { - return this.salary + (this.salary * percent)/100; - } - - public String toString() { - return this.getFullName() + " - " + "salary: " + this.salary; - } -} - - diff --git a/exercise_oop_employee/src/Main.java b/exercise_oop_employee/src/Main.java deleted file mode 100644 index 342c48f..0000000 --- a/exercise_oop_employee/src/Main.java +++ /dev/null @@ -1,10 +0,0 @@ -public class Main { - - public static void main(String[] args) { - Employee employee = new Employee(1, "Nguyen", "Sin", 10000000); - System.out.println(employee.getFullName()); - System.out.println(employee.getAnnualSalary()); - System.out.println(employee.toString()); - System.out.println("Salary up to: " + employee.upToSalary(10)); - } -} diff --git a/exercise_oop_inheritance_circle_cylinder/exercise_oop_inheritance_circle_cylinder.iml b/exercise_oop_inheritance_circle_cylinder/exercise_oop_inheritance_circle_cylinder.iml deleted file mode 100644 index c90834f..0000000 --- a/exercise_oop_inheritance_circle_cylinder/exercise_oop_inheritance_circle_cylinder.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/exercise_oop_inheritance_circle_cylinder/src/Circle.java b/exercise_oop_inheritance_circle_cylinder/src/Circle.java deleted file mode 100644 index bb6a581..0000000 --- a/exercise_oop_inheritance_circle_cylinder/src/Circle.java +++ /dev/null @@ -1,36 +0,0 @@ -public class Circle { - private double radius; - private String color; - - public Circle(double radius, String color) { - this.radius = radius; - this.color = color; - } - - public double getRadius() { - return radius; - } - - public void setRadius(double radius) { - this.radius = radius; - } - - public String getColor() { - return color; - } - - public void setColor(String color) { - this.color = color; - } - - public double getArea() { - return this.radius * this.radius * Math.PI; - } - - public String toString() { - return "Circle{" + - "radius=" + radius + - ", color='" + color + '\'' + - '}'; - } -} diff --git a/exercise_oop_inheritance_circle_cylinder/src/Cylinder.java b/exercise_oop_inheritance_circle_cylinder/src/Cylinder.java deleted file mode 100644 index 5cda15a..0000000 --- a/exercise_oop_inheritance_circle_cylinder/src/Cylinder.java +++ /dev/null @@ -1,21 +0,0 @@ -public class Cylinder extends Circle { - private double heigth; - - public Cylinder(double radius, String color, double heigth) { - super(radius, color); - this.heigth = heigth; - } - - public double getHeigth() { - return heigth; - } - - public void setHeigth(double heigth) { - this.heigth = heigth; - } - - public double getVolumer() { - return super.getArea() * this.heigth; - } - -} diff --git a/exercise_oop_inheritance_circle_cylinder/src/Main.java b/exercise_oop_inheritance_circle_cylinder/src/Main.java deleted file mode 100644 index 51647e6..0000000 --- a/exercise_oop_inheritance_circle_cylinder/src/Main.java +++ /dev/null @@ -1,8 +0,0 @@ -public class Main { - - public static void main(String[] args) { - Circle cylinder = new Cylinder(2.4, "red", 10); - System.out.println("Area: " + cylinder.getArea()); - System.out.println("Volume: " + ((Cylinder) cylinder).getVolumer()); - } -} diff --git a/exercise_oop_inheritance_person_student_staff/exercise_oop_inheritance_person_student_staff.iml b/exercise_oop_inheritance_person_student_staff/exercise_oop_inheritance_person_student_staff.iml deleted file mode 100644 index c90834f..0000000 --- a/exercise_oop_inheritance_person_student_staff/exercise_oop_inheritance_person_student_staff.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/exercise_oop_inheritance_person_student_staff/src/Main.java b/exercise_oop_inheritance_person_student_staff/src/Main.java deleted file mode 100644 index 88e73ab..0000000 --- a/exercise_oop_inheritance_person_student_staff/src/Main.java +++ /dev/null @@ -1,10 +0,0 @@ -public class Main { - - public static void main(String[] args) { - Person student = new Student("H", "DN", "CHINH QUY", 3, 6.7); - Person staff = new Staff("D", "BT", "KHTN", 12.5); - System.out.println(((Student) student).getRating()); - System.out.println(((Staff) staff).upToSalary(40)); - - } -} diff --git a/exercise_oop_inheritance_person_student_staff/src/Person.java b/exercise_oop_inheritance_person_student_staff/src/Person.java deleted file mode 100644 index f5176ef..0000000 --- a/exercise_oop_inheritance_person_student_staff/src/Person.java +++ /dev/null @@ -1,17 +0,0 @@ -public class Person { - private String name; - private String address; - - public Person(String name, String address) { - this.name = name; - this.address = address; - } - - public String getAddress() { - return address; - } - - public String getName() { - return name; - } -} diff --git a/exercise_oop_inheritance_person_student_staff/src/Staff.java b/exercise_oop_inheritance_person_student_staff/src/Staff.java deleted file mode 100644 index e1d1a9b..0000000 --- a/exercise_oop_inheritance_person_student_staff/src/Staff.java +++ /dev/null @@ -1,31 +0,0 @@ -public class Staff extends Person { - - private String school; - private double salary; - - public Staff(String name, String address, String school, double salary) { - super(name, address); - this.school = school; - this.salary = salary; - } - - public String getSchool() { - return school; - } - - public void setSchool(String school) { - this.school = school; - } - - public double getSalary() { - return salary; - } - - public void setSalary(double salary) { - this.salary = salary; - } - - public double upToSalary(int percent) { - return this.salary + (this.salary * percent) / 100; - } -} diff --git a/exercise_oop_inheritance_person_student_staff/src/Student.java b/exercise_oop_inheritance_person_student_staff/src/Student.java deleted file mode 100644 index 1a125de..0000000 --- a/exercise_oop_inheritance_person_student_staff/src/Student.java +++ /dev/null @@ -1,47 +0,0 @@ -public class Student extends Person{ - private String program; - private int year; - private double score; - - public Student(String name, String address, String program, int year, double score) { - super(name, address); - this.program = program; - this.year = year; - this.score = score; - } - - 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 getScore() { - return score; - } - - public void setScore(double score) { - this.score = score; - } - - public String getRating() { - if (this.score < 5) { - return "bad"; - } else if (this.score >= 5 && this.score <8) { - return "medium"; - } else { - return "good"; - } - } - -} diff --git a/exercise_oop_polymorphism_interface_moveable/exercise_oop_polymorphism_interface_moveable.iml b/exercise_oop_polymorphism_interface_moveable/exercise_oop_polymorphism_interface_moveable.iml deleted file mode 100644 index c90834f..0000000 --- a/exercise_oop_polymorphism_interface_moveable/exercise_oop_polymorphism_interface_moveable.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/exercise_oop_polymorphism_interface_moveable/src/Main.java b/exercise_oop_polymorphism_interface_moveable/src/Main.java deleted file mode 100644 index e07f4eb..0000000 --- a/exercise_oop_polymorphism_interface_moveable/src/Main.java +++ /dev/null @@ -1,16 +0,0 @@ -public class Main { - - public static void main(String[] args) { - MoveablePoint moveablePoint = new MoveablePoint(10, 5, 1,1); - MoveableCircle moveableCircle = new MoveableCircle(moveablePoint, 4); - System.out.println(moveableCircle.toString()); - moveableCircle.moveRight(); - System.out.println(moveableCircle.toString()); - moveableCircle.moveUp(); - System.out.println(moveableCircle.toString()); - moveableCircle.moveLeft(); - System.out.println(moveableCircle.toString()); - moveableCircle.moveDown(); - System.out.println(moveableCircle.toString()); - } -} diff --git a/exercise_oop_polymorphism_interface_moveable/src/Moveable.java b/exercise_oop_polymorphism_interface_moveable/src/Moveable.java deleted file mode 100644 index 9cda3d9..0000000 --- a/exercise_oop_polymorphism_interface_moveable/src/Moveable.java +++ /dev/null @@ -1,6 +0,0 @@ -public interface Moveable { - void moveUp(); - void moveDown(); - void moveLeft(); - void moveRight(); -} diff --git a/exercise_oop_polymorphism_interface_moveable/src/MoveableCircle.java b/exercise_oop_polymorphism_interface_moveable/src/MoveableCircle.java deleted file mode 100644 index 037c7db..0000000 --- a/exercise_oop_polymorphism_interface_moveable/src/MoveableCircle.java +++ /dev/null @@ -1,35 +0,0 @@ -public class MoveableCircle implements Moveable{ - - private MoveablePoint center; - private double radius; - - public MoveableCircle(MoveablePoint center, double radius) { - this.center = center; - this.radius = radius; - } - - @Override - public void moveUp() { - this.center.setX(this.center.getX() + this.center.getxSpeed()); - } - - @Override - public void moveDown() { - this.center.setX(this.center.getX() - this.center.getxSpeed()); - } - - @Override - public void moveLeft() { - this.center.setY(this.center.getY() - this.center.getySpeed()); - } - - @Override - public void moveRight() { - this.center.setY(this.center.getY() + this.center.getySpeed()); - } - - @Override - public String toString() { - return "Center: " + "(" + this.center.getX() + ", "+ this.center.getY() + ")"; - } -} diff --git a/exercise_oop_polymorphism_interface_moveable/src/MoveablePoint.java b/exercise_oop_polymorphism_interface_moveable/src/MoveablePoint.java deleted file mode 100644 index 8543190..0000000 --- a/exercise_oop_polymorphism_interface_moveable/src/MoveablePoint.java +++ /dev/null @@ -1,76 +0,0 @@ -public class MoveablePoint implements Moveable { - private int x; - private int y; - private int xSpeed; - private int ySpeed; - - public MoveablePoint(int x, int y, int xSpeed, int ySpeed) { - this.x = x; - this.y = y; - this.xSpeed = xSpeed; - this.ySpeed = ySpeed; - } - - @Override - public void moveUp() { - this.x += this.xSpeed; - - } - - @Override - public void moveDown() { - this.x -= this.xSpeed; - } - - @Override - public void moveLeft() { - this.y -= this.ySpeed; - } - - @Override - public void moveRight() { - this.y += this.ySpeed; - } - - public int getX() { - return x; - } - - public void setX(int x) { - this.x = x; - } - - public int getY() { - return y; - } - - public void setY(int y) { - this.y = y; - } - - public int getxSpeed() { - return xSpeed; - } - - public void setxSpeed(int xSpeed) { - this.xSpeed = xSpeed; - } - - public int getySpeed() { - return ySpeed; - } - - public void setySpeed(int ySpeed) { - this.ySpeed = ySpeed; - } - - @Override - public String toString() { - return "MoveablePoint{" + - "x=" + x + - ", y=" + y + - ", xSpeed=" + xSpeed + - ", ySpeed=" + ySpeed + - '}'; - } -} diff --git a/exercise_polymorphism/Circle.java b/exercise_polymorphism/Circle.java deleted file mode 100644 index 5d0e6a4..0000000 --- a/exercise_polymorphism/Circle.java +++ /dev/null @@ -1,38 +0,0 @@ -public class Circle extends Shape { - private double radius; - - public Circle() { - } - - public Circle(double radius) { - this.radius = radius; - } - - public Circle(String color, boolean filled, double radius) { - super(color, filled); - this.radius = radius; - } - - public double getRadius() { - return radius; - } - - public void setRadius(double radius) { - this.radius = radius; - } - - @Override - public double getArea() { - return Math.PI * this.radius * this.radius; - } - - @Override - public double getPerimeter() { - return this.radius * 2 * Math.PI; - } - - @Override - public String toString() { - return this.radius + " - " + this.color + " - " + this.filled; - } -} diff --git a/exercise_polymorphism/Main.java b/exercise_polymorphism/Main.java deleted file mode 100644 index 722548b..0000000 --- a/exercise_polymorphism/Main.java +++ /dev/null @@ -1,53 +0,0 @@ -public class Main { - - public static void main(String[] args) { - Shape s1 = new Circle("RED", true, 5.5); - System.out.println(s1); - System.out.println(s1.getArea()); // which version? - System.out.println(s1.getPerimeter()); // which version? - System.out.println(s1.getColor()); - System.out.println(s1.isFilled()); - System.out.println(((Circle) s1).getRadius()); - - Circle c1 = (Circle)s1; - System.out.println(c1); - System.out.println(c1.getArea()); - System.out.println(c1.getPerimeter()); - System.out.println(c1.getColor()); - System.out.println(c1.isFilled()); - System.out.println(c1.getRadius()); - - Shape s3 = new Rectangle("RED", false, 4.5, 7.5); - System.out.println(s3); - System.out.println(s3.getArea()); - System.out.println(s3.getPerimeter()); - System.out.println(s3.getColor()); - System.out.println(((Rectangle) s3).getLength()); - - Rectangle r1 = (Rectangle)s3; - System.out.println(r1); - System.out.println(r1.getArea()); - System.out.println(r1.getColor()); - System.out.println(r1.getLength()); - - Shape s4 = new Square(6.6); - System.out.println(s4); - System.out.println(s4.getArea()); - System.out.println(s4.getColor()); - System.out.println(((Square) s4).getWidth()); - - Rectangle r2 = (Rectangle)s4; - System.out.println(r2); - System.out.println(r2.getArea()); - System.out.println(r2.getColor()); - System.out.println(r2.getWidth()); - System.out.println(r2.getLength()); - - Square sq1 = (Square)r2; - System.out.println(sq1); - System.out.println(sq1.getArea()); - System.out.println(sq1.getColor()); - System.out.println(sq1.getWidth()); - System.out.println(sq1.getLength()); - } -} diff --git a/exercise_polymorphism/Rectangle.java b/exercise_polymorphism/Rectangle.java deleted file mode 100644 index 1c3ddaa..0000000 --- a/exercise_polymorphism/Rectangle.java +++ /dev/null @@ -1,50 +0,0 @@ -public class Rectangle extends Shape{ - - protected double width; - protected double length; - - public Rectangle() { - } - - public Rectangle(double width, double length) { - this.width = width; - this.length = length; - } - - public Rectangle(String color, boolean filled, double width, double length) { - super(color, filled); - this.width = width; - this.length = length; - } - - public double getWidth() { - return width; - } - - public void setWidth(double width) { - this.width = width; - } - - public double getLength() { - return length; - } - - public void setLength(double length) { - this.length = length; - } - - @Override - public double getArea() { - return this.width * this.length; - } - - @Override - public double getPerimeter() { - return this.width + this.length; - } - - @Override - public String toString() { - return this.width + " - " + this.length + " - " + this.color + " - " + this.filled; - } -} diff --git a/exercise_polymorphism/Shape.java b/exercise_polymorphism/Shape.java deleted file mode 100644 index 6e5e840..0000000 --- a/exercise_polymorphism/Shape.java +++ /dev/null @@ -1,32 +0,0 @@ -public abstract class Shape { - protected String color; - protected boolean filled; - - public Shape() {} - - public Shape(String color, boolean filled) { - this.color = color; - this.filled = filled; - } - - public String getColor() { - return color; - } - - public void setColor(String color) { - this.color = color; - } - - public boolean isFilled() { - return filled; - } - - public void setFilled(boolean filled) { - this.filled = filled; - } - - public abstract double getArea(); - public abstract double getPerimeter(); - public abstract String toString(); - -} diff --git a/exercise_polymorphism/Square.java b/exercise_polymorphism/Square.java deleted file mode 100644 index 39a15e9..0000000 --- a/exercise_polymorphism/Square.java +++ /dev/null @@ -1,12 +0,0 @@ -public class Square extends Rectangle { - public Square() { - } - - public Square(double side) { - super(side, side); - } - - public Square(String color, boolean filled, double side) { - super(color, filled, side, side); - } -} diff --git a/exerciseoop_class-object_cricle/exerciseoop_class-object_cricle.iml b/exerciseoop_class-object_cricle/exerciseoop_class-object_cricle.iml deleted file mode 100644 index c90834f..0000000 --- a/exerciseoop_class-object_cricle/exerciseoop_class-object_cricle.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/exerciseoop_class-object_cricle/src/com/company/Circle.java b/exerciseoop_class-object_cricle/src/com/company/Circle.java deleted file mode 100644 index c83d198..0000000 --- a/exerciseoop_class-object_cricle/src/com/company/Circle.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.company; - -public class Circle { - private double radius; - private String color; - - public Circle() { - this.radius = 1.0; - this.color = "red"; - } - - public Circle(double radius) { - this.radius = radius; - this.color = "red"; - } - - public Circle(double radius, String color) { - this.radius = radius; - this.color = color; - } - - public double getRadius() { - return radius; - } - - public void setRadius(double radius) { - this.radius = radius; - } - - public String getColor() { - return color; - } - - public void setColor(String color) { - this.color = color; - } - - public double getArea() { - return this.radius * this.radius * Math.PI; - } - - public String toString() { - return "Radius: " + this.radius + " - Color: " + this.color; - } -} diff --git a/exerciseoop_class-object_cricle/src/com/company/Main.java b/exerciseoop_class-object_cricle/src/com/company/Main.java deleted file mode 100644 index 304d1d5..0000000 --- a/exerciseoop_class-object_cricle/src/com/company/Main.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.company; - -public class Main { - - public static void main(String[] args) { - // Test default constructor - Circle circle1 = new Circle(); - display(circle1); - - // Test constructor has 1 parameter radius - Circle circle2 = new Circle(2.0); - display(circle2); - - // Test constructor has 2 parameter radius, color - Circle circle3 = new Circle(2.0, "blue"); - display(circle3); - - // Test getter setter - Circle circle4 = new Circle(); - circle4.setColor("Green"); - circle4.setRadius(3.0); - display(circle4); - - - - } - - public static void display(Circle circle) { - System.out.println(circle.toString()); - System.out.println("Area: " + circle.getArea()); - System.out.println(); - } -} \ No newline at end of file diff --git a/exerciseoop_class-object_rectangle/exerciseoop_class-object_rectangle.iml b/exerciseoop_class-object_rectangle/exerciseoop_class-object_rectangle.iml deleted file mode 100644 index c90834f..0000000 --- a/exerciseoop_class-object_rectangle/exerciseoop_class-object_rectangle.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/exerciseoop_class-object_rectangle/src/com/company/Main.java b/exerciseoop_class-object_rectangle/src/com/company/Main.java deleted file mode 100644 index 2765487..0000000 --- a/exerciseoop_class-object_rectangle/src/com/company/Main.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.company; - -public class Main { - - public static void main(String[] args) { - Rectangle rectangle1 = new Rectangle(); - rectangle1.setLength(10); - rectangle1.setWidth(13); - System.out.println(rectangle1.toString()); - System.out.println("Area: " + rectangle1.getArea()); - } -} diff --git a/exerciseoop_class-object_rectangle/src/com/company/Rectangle.java b/exerciseoop_class-object_rectangle/src/com/company/Rectangle.java deleted file mode 100644 index 176f3d1..0000000 --- a/exerciseoop_class-object_rectangle/src/com/company/Rectangle.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.company; - -public class Rectangle { - private int length; - private int width; - - public Rectangle() {} - - public Rectangle(int length, int width) { - this.length = length; - this.width = width; - } - - public int getLength() { - return length; - } - - public void setLength(int length) { - this.length = length; - } - - public int getWidth() { - return width; - } - - public void setWidth(int width) { - this.width = width; - } - - public int getArea() { - return this.length * this.width; - } - - public String toString() { - return "Length: " + this.length + " - Width: " + this.width; - } -} diff --git a/oop-b14/oop-b14.iml b/oop-b14/oop-b14.iml deleted file mode 100644 index e7b98ac..0000000 --- a/oop-b14/oop-b14.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/oop-b14/src/Main.java b/oop-b14/src/Main.java deleted file mode 100644 index c0830d8..0000000 --- a/oop-b14/src/Main.java +++ /dev/null @@ -1,33 +0,0 @@ -import entity.GoodStudent; -import entity.NormalStudent; - -import java.util.Arrays; -import java.util.Comparator; -import java.util.List; -import java.util.stream.Collectors; - -public class Main { - public static void main(String[] args) { - // DEMO cho câu 14 yêu cầu 3 - List goodStudent = Arrays.asList( - new GoodStudent("Nguyễn Văn D","", "", "", "", "", 7.3f, ""), - new GoodStudent("Nguyễn Văn B","", "", "", "", "", 7.2f, ""), - new GoodStudent("Nguyễn Văn A", "", "", "", "", "", 7.2f, ""), - new GoodStudent("Nguyễn Văn C","", "", "", "", "", 7.3f, "") - ); - System.out.println("abc"); - List lgs = getSortedGoodStudentList(goodStudent).subList(0, 2); - lgs.forEach(System.out::println); - } - - - public static List getSortedGoodStudentList(List playerList) { - return playerList.stream().sorted(Comparator.comparing(GoodStudent::getGpa).reversed() - .thenComparing(GoodStudent::getLastName)).collect(Collectors.toList()); - } - - public static List getSortedNormalStudentList(List playerList) { - return playerList.stream().sorted(Comparator.comparing(NormalStudent::getEnglishScore).reversed() - .thenComparing(NormalStudent::getLastName)).collect(Collectors.toList()); - } -} diff --git a/oop-b14/src/entity/GoodStudent.java b/oop-b14/src/entity/GoodStudent.java deleted file mode 100644 index dc32c2c..0000000 --- a/oop-b14/src/entity/GoodStudent.java +++ /dev/null @@ -1,18 +0,0 @@ -package entity; - -public class GoodStudent extends Student { - Float gpa; - String bestRewardName; - - - public GoodStudent(String fullName, String dob, String gender, String phoneNumber, String universityName, String gradeLevel, Float gpa, String bestRewardName) { - super(fullName, dob, gender, phoneNumber, universityName, gradeLevel); - this.gpa = gpa; - this.bestRewardName = bestRewardName; - } - - public Float getGpa() { - return gpa; - } - -} diff --git a/oop-b14/src/entity/NormalStudent.java b/oop-b14/src/entity/NormalStudent.java deleted file mode 100644 index ccfd98c..0000000 --- a/oop-b14/src/entity/NormalStudent.java +++ /dev/null @@ -1,16 +0,0 @@ -package entity; - -public class NormalStudent extends Student{ - Integer englishScore; - Float entryTestScore; - - public NormalStudent(String fullName, String dob, String gender, String phoneNumber, String universityName, String gradeLevel, Integer englishScore, Float entryTestScore) { - super(fullName, dob, gender, phoneNumber, universityName, gradeLevel); - this.englishScore = englishScore; - this.entryTestScore = entryTestScore; - } - - public Integer getEnglishScore() { - return englishScore; - } -} diff --git a/oop-b14/src/entity/Student.java b/oop-b14/src/entity/Student.java deleted file mode 100644 index ce00b40..0000000 --- a/oop-b14/src/entity/Student.java +++ /dev/null @@ -1,24 +0,0 @@ -package entity; - -public class Student { - String fullName; - String dob; - String gender; - String phoneNumber; - String universityName; - String gradeLevel; - - public Student(String fullName, String dob, String gender, String phoneNumber, String universityName, String gradeLevel) { - this.fullName = fullName; - this.dob = dob; - this.gender = gender; - this.phoneNumber = phoneNumber; - this.universityName = universityName; - this.gradeLevel = gradeLevel; - } - - public String getLastName() { - String[] nameSplit = fullName.split(" "); - return nameSplit[nameSplit.length - 1]; - } -} diff --git a/oop-shareprogramming.iml b/oop-shareprogramming.iml deleted file mode 100644 index c6f833d..0000000 --- a/oop-shareprogramming.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/oop_employee_management/.idea/.gitignore b/oop_employee_management/.idea/.gitignore deleted file mode 100644 index 26d3352..0000000 --- a/oop_employee_management/.idea/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml diff --git a/oop_employee_management/.idea/misc.xml b/oop_employee_management/.idea/misc.xml deleted file mode 100644 index 0548357..0000000 --- a/oop_employee_management/.idea/misc.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/oop_employee_management/.idea/modules.xml b/oop_employee_management/.idea/modules.xml deleted file mode 100644 index 76c0135..0000000 --- a/oop_employee_management/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/oop_employee_management/.idea/uiDesigner.xml b/oop_employee_management/.idea/uiDesigner.xml deleted file mode 100644 index e96534f..0000000 --- a/oop_employee_management/.idea/uiDesigner.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/oop_employee_management/.idea/vcs.xml b/oop_employee_management/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/oop_employee_management/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/oop_employee_management/README.md b/oop_employee_management/README.md deleted file mode 100644 index c203d41..0000000 --- a/oop_employee_management/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# oop_employee_management - - - -## Getting started - -Bản code prototype cho bài 13 trong bộ bài tập tổng hợp tại [Deft blog](https://shareprogramming.net/tong-hop-bai-tap-lap-trinh-huong-doi-tuong-trong-java/) - -Các bạn có thể dựa vào đây, để lấy ý tưởng và triển khai bài hoàn chỉnh. - - diff --git a/oop_employee_management/oop_b13.iml b/oop_employee_management/oop_b13.iml deleted file mode 100644 index c90834f..0000000 --- a/oop_employee_management/oop_b13.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/oop_employee_management/oop_employee_management.iml b/oop_employee_management/oop_employee_management.iml deleted file mode 100644 index c90834f..0000000 --- a/oop_employee_management/oop_employee_management.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/oop_employee_management/out/production/oop_b13/Main.class b/oop_employee_management/out/production/oop_b13/Main.class deleted file mode 100644 index 725e64c..0000000 Binary files a/oop_employee_management/out/production/oop_b13/Main.class and /dev/null differ diff --git a/oop_employee_management/out/production/oop_b13/entity/Certificate.class b/oop_employee_management/out/production/oop_b13/entity/Certificate.class deleted file mode 100644 index e33d657..0000000 Binary files a/oop_employee_management/out/production/oop_b13/entity/Certificate.class and /dev/null differ diff --git a/oop_employee_management/out/production/oop_b13/entity/Employee.class b/oop_employee_management/out/production/oop_b13/entity/Employee.class deleted file mode 100644 index f1d5b0b..0000000 Binary files a/oop_employee_management/out/production/oop_b13/entity/Employee.class and /dev/null differ diff --git a/oop_employee_management/out/production/oop_b13/entity/Experience.class b/oop_employee_management/out/production/oop_b13/entity/Experience.class deleted file mode 100644 index 5a148a3..0000000 Binary files a/oop_employee_management/out/production/oop_b13/entity/Experience.class and /dev/null differ diff --git a/oop_employee_management/out/production/oop_b13/entity/Fresher.class b/oop_employee_management/out/production/oop_b13/entity/Fresher.class deleted file mode 100644 index cfe7401..0000000 Binary files a/oop_employee_management/out/production/oop_b13/entity/Fresher.class and /dev/null differ diff --git a/oop_employee_management/out/production/oop_b13/entity/Intern.class b/oop_employee_management/out/production/oop_b13/entity/Intern.class deleted file mode 100644 index d5c6bf6..0000000 Binary files a/oop_employee_management/out/production/oop_b13/entity/Intern.class and /dev/null differ diff --git a/oop_employee_management/out/production/oop_b13/exception/BirthDayException.class b/oop_employee_management/out/production/oop_b13/exception/BirthDayException.class deleted file mode 100644 index 123bac5..0000000 Binary files a/oop_employee_management/out/production/oop_b13/exception/BirthDayException.class and /dev/null differ diff --git a/oop_employee_management/out/production/oop_b13/exception/EmailException.class b/oop_employee_management/out/production/oop_b13/exception/EmailException.class deleted file mode 100644 index 184d350..0000000 Binary files a/oop_employee_management/out/production/oop_b13/exception/EmailException.class and /dev/null differ diff --git a/oop_employee_management/out/production/oop_b13/exception/FullNameException.class b/oop_employee_management/out/production/oop_b13/exception/FullNameException.class deleted file mode 100644 index 9c14fe4..0000000 Binary files a/oop_employee_management/out/production/oop_b13/exception/FullNameException.class and /dev/null differ diff --git a/oop_employee_management/out/production/oop_b13/exception/PhoneException.class b/oop_employee_management/out/production/oop_b13/exception/PhoneException.class deleted file mode 100644 index aa55fb9..0000000 Binary files a/oop_employee_management/out/production/oop_b13/exception/PhoneException.class and /dev/null differ diff --git a/oop_employee_management/out/production/oop_b13/service/EmployeeManager.class b/oop_employee_management/out/production/oop_b13/service/EmployeeManager.class deleted file mode 100644 index f5d46a0..0000000 Binary files a/oop_employee_management/out/production/oop_b13/service/EmployeeManager.class and /dev/null differ diff --git a/oop_employee_management/out/production/oop_b13/ui/ScannerFactory.class b/oop_employee_management/out/production/oop_b13/ui/ScannerFactory.class deleted file mode 100644 index 79a40d1..0000000 Binary files a/oop_employee_management/out/production/oop_b13/ui/ScannerFactory.class and /dev/null differ diff --git a/oop_employee_management/out/production/oop_b13/ui/UIManager.class b/oop_employee_management/out/production/oop_b13/ui/UIManager.class deleted file mode 100644 index d9bd529..0000000 Binary files a/oop_employee_management/out/production/oop_b13/ui/UIManager.class and /dev/null differ diff --git a/oop_employee_management/src/Main.java b/oop_employee_management/src/Main.java deleted file mode 100644 index 618e1f5..0000000 --- a/oop_employee_management/src/Main.java +++ /dev/null @@ -1,29 +0,0 @@ -import ui.ScannerFactory; -import ui.UIManager; - -import java.util.Scanner; - -public class Main { - public static void main(String[] args) { - UIManager uiManager = new UIManager(); - Scanner scanner = ScannerFactory.getScanner(); - Integer ch = scanner.nextInt(); - while (true) { - System.out.println("Application"); - System.out.println("Enter 1: To insert "); - System.out.println("Enter 2: To search: "); - // TODO HERE - System.out.println("Enter 4: To exit:"); - switch (ch) { - case 1: { - // input 0 => insert Experience - // input 1 => insert Fresher - // input 2 => insert Intern - int type = scanner.nextInt(); - uiManager.insert(type); - } - // TODO HERE - } - } - } -} diff --git a/oop_employee_management/src/entity/Certificate.java b/oop_employee_management/src/entity/Certificate.java deleted file mode 100644 index 359db6a..0000000 --- a/oop_employee_management/src/entity/Certificate.java +++ /dev/null @@ -1,52 +0,0 @@ -package entity; - -import java.time.LocalDate; - -public class Certificate { - private String id; - private String name; - private String rank; - private LocalDate date; - - public Certificate() { - } - - public Certificate(String id, String name, String rank, LocalDate date) { - this.id = id; - this.name = name; - this.rank = rank; - this.date = date; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getRank() { - return rank; - } - - public void setRank(String rank) { - this.rank = rank; - } - - public LocalDate getDate() { - return date; - } - - public void setDate(LocalDate date) { - this.date = date; - } -} diff --git a/oop_employee_management/src/entity/Employee.java b/oop_employee_management/src/entity/Employee.java deleted file mode 100644 index 8873ec4..0000000 --- a/oop_employee_management/src/entity/Employee.java +++ /dev/null @@ -1,75 +0,0 @@ -package entity; - -import java.time.LocalDate; -import java.util.List; - -public abstract class Employee { - public static long count = 0; - protected String id; - protected String fullName; - protected LocalDate birthday; - protected String phone; - protected String email; - protected List certificates; - - public Employee() {} - - public Employee(String id, String fullName, LocalDate birthday, String phone, String email, List certificates) { - this.id = id; - this.fullName = fullName; - this.birthday = birthday; - this.phone = phone; - this.email = email; - this.certificates = certificates; - } - - public abstract void showInformation(); - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getFullName() { - return fullName; - } - - public void setFullName(String fullName) { - this.fullName = fullName; - } - - public LocalDate getBirthday() { - return birthday; - } - - public void setBirthday(LocalDate birthday) { - this.birthday = birthday; - } - - public String getPhone() { - return phone; - } - - public void setPhone(String phone) { - this.phone = phone; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public List getCertificates() { - return certificates; - } - - public void setCertificates(List certificates) { - this.certificates = certificates; - } -} diff --git a/oop_employee_management/src/entity/Experience.java b/oop_employee_management/src/entity/Experience.java deleted file mode 100644 index 005dfe7..0000000 --- a/oop_employee_management/src/entity/Experience.java +++ /dev/null @@ -1,57 +0,0 @@ -package entity; - -import java.time.LocalDate; -import java.util.List; - -public class Experience extends Employee { - private int yearOfExperience; - private String proSkill; - - public Experience() { - } - - public Experience(int yearOfExperience, String proSkill) { - this.yearOfExperience = yearOfExperience; - this.proSkill = proSkill; - } - - public Experience(String id, String fullName, LocalDate birthday, String phone, String email, List certificates, int yearOfExperience, String proSkill) { - super(id, fullName, birthday, phone, email, certificates); - this.yearOfExperience = yearOfExperience; - this.proSkill = proSkill; - } - - @Override - public void showInformation() { - System.out.println(this); - } - - public int getYearOfExperience() { - return yearOfExperience; - } - - public void setYearOfExperience(int yearOfExperience) { - this.yearOfExperience = yearOfExperience; - } - - public String getProSkill() { - return proSkill; - } - - public void setProSkill(String proSkill) { - this.proSkill = proSkill; - } - - @Override - public String toString() { - return "Experience{" + - "id='" + id + '\'' + - ", fullName='" + fullName + '\'' + - ", birthday=" + birthday + - ", phone='" + phone + '\'' + - ", email='" + email + '\'' + - ", yearOfExperience=" + yearOfExperience + - ", proSkill='" + proSkill + '\'' + - '}'; - } -} diff --git a/oop_employee_management/src/entity/Fresher.java b/oop_employee_management/src/entity/Fresher.java deleted file mode 100644 index 993a6a6..0000000 --- a/oop_employee_management/src/entity/Fresher.java +++ /dev/null @@ -1,70 +0,0 @@ -package entity; - -import java.time.LocalDate; -import java.util.List; - -public class Fresher extends Employee { - - private LocalDate graduationDate; - private String graduationRank; - private String universityName; - - public Fresher() { - } - - public Fresher(LocalDate graduationDate, String graduationRank, String universityName) { - this.graduationDate = graduationDate; - this.graduationRank = graduationRank; - this.universityName = universityName; - } - - public Fresher(String id, String fullName, LocalDate birthday, String phone, String email, List certificates, LocalDate graduationDate, String graduationRank, String universityName) { - super(id, fullName, birthday, phone, email, certificates); - this.graduationDate = graduationDate; - this.graduationRank = graduationRank; - this.universityName = universityName; - } - - @Override - public void showInformation() { - System.out.println(this); - } - - public LocalDate getGraduationDate() { - return graduationDate; - } - - public void setGraduationDate(LocalDate graduationDate) { - this.graduationDate = graduationDate; - } - - public String getGraduationRank() { - return graduationRank; - } - - public void setGraduationRank(String graduationRank) { - this.graduationRank = graduationRank; - } - - public String getEducation() { - return universityName; - } - - public void setEducation(String education) { - this.universityName = education; - } - - @Override - public String toString() { - return "Fresher{" + - "id='" + id + '\'' + - ", fullName='" + fullName + '\'' + - ", birthday=" + birthday + - ", phone='" + phone + '\'' + - ", email='" + email + '\'' + - ", graduationDate=" + graduationDate + - ", graduationRank='" + graduationRank + '\'' + - ", universityName='" + universityName + '\'' + - '}'; - } -} diff --git a/oop_employee_management/src/entity/Intern.java b/oop_employee_management/src/entity/Intern.java deleted file mode 100644 index 61d19b5..0000000 --- a/oop_employee_management/src/entity/Intern.java +++ /dev/null @@ -1,69 +0,0 @@ -package entity; - -import java.time.LocalDate; -import java.util.List; - -public class Intern extends Employee { - private String major; - private int semester; - private String universityName; - - public Intern() { - } - - public Intern(String major, int semester, String universityName) { - this.major = major; - this.semester = semester; - this.universityName = universityName; - } - - public Intern(String id, String fullName, LocalDate birthday, String phone, String email, List certificates, String major, int semester, String universityName) { - super(id, fullName, birthday, phone, email, certificates); - this.major = major; - this.semester = semester; - this.universityName = universityName; - } - - @Override - public void showInformation() { - System.out.println(this); - } - - public String getMajor() { - return major; - } - - public void setMajor(String major) { - this.major = major; - } - - public int getSemester() { - return semester; - } - - public void setSemester(int semester) { - this.semester = semester; - } - - public String getUniversityName() { - return universityName; - } - - public void setUniversityName(String universityName) { - this.universityName = universityName; - } - - @Override - public String toString() { - return "Intern{" + - "id='" + id + '\'' + - ", fullName='" + fullName + '\'' + - ", birthday=" + birthday + - ", phone='" + phone + '\'' + - ", email='" + email + '\'' + - ", major='" + major + '\'' + - ", semester=" + semester + - ", universityName='" + universityName + '\'' + - '}'; - } -} diff --git a/oop_employee_management/src/exception/BirthDayException.java b/oop_employee_management/src/exception/BirthDayException.java deleted file mode 100644 index cdeb54f..0000000 --- a/oop_employee_management/src/exception/BirthDayException.java +++ /dev/null @@ -1,7 +0,0 @@ -package exception; - -public class BirthDayException extends Exception { - public BirthDayException(String message) { - super(message); - } -} diff --git a/oop_employee_management/src/exception/EmailException.java b/oop_employee_management/src/exception/EmailException.java deleted file mode 100644 index 24688f7..0000000 --- a/oop_employee_management/src/exception/EmailException.java +++ /dev/null @@ -1,4 +0,0 @@ -package exception; - -public class EmailException extends Exception { -} diff --git a/oop_employee_management/src/exception/FullNameException.java b/oop_employee_management/src/exception/FullNameException.java deleted file mode 100644 index c9a6977..0000000 --- a/oop_employee_management/src/exception/FullNameException.java +++ /dev/null @@ -1,8 +0,0 @@ -package exception; - -public class FullNameException extends Exception { - - public FullNameException(String message) { - super(message); - } -} diff --git a/oop_employee_management/src/exception/PhoneException.java b/oop_employee_management/src/exception/PhoneException.java deleted file mode 100644 index c46a667..0000000 --- a/oop_employee_management/src/exception/PhoneException.java +++ /dev/null @@ -1,8 +0,0 @@ -package exception; - -public class PhoneException extends Exception { - - public PhoneException(String message) { - super(message); - } -} diff --git a/oop_employee_management/src/service/EmployeeManager.java b/oop_employee_management/src/service/EmployeeManager.java deleted file mode 100644 index 9a88348..0000000 --- a/oop_employee_management/src/service/EmployeeManager.java +++ /dev/null @@ -1,64 +0,0 @@ -package service; - -import entity.Employee; -import entity.Experience; -import entity.Fresher; -import entity.Intern; - -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -public class EmployeeManager { - - private List employees; - - public EmployeeManager() { - this.employees = new ArrayList<>(); - } - - public void insert(Employee employee) { - this.employees.add(employee); - } - - public Employee findById(String id) { - return this.employees.stream().filter(employee -> employee.getId().equals(id)).findFirst().orElse(null); - } - - public boolean deleteById(String id) { - Employee employee = this.findById(id); - if (employee == null) { - return false; - } - this.employees.remove(employee); - return true; - } - - /** - * type = 0 => Experience - * type = 1 => Fresher - * type = 2 => Intern - */ - public List findByType(int type) { - return this.employees.stream() - .filter(employee -> { - if (type == 0) { - return employee instanceof Experience; - } - if (type == 1) { - return employee instanceof Fresher; - } - if (type == 2) { - return employee instanceof Intern; - } - return false; - }) - .collect(Collectors.toList()); - } - - public List findAll() { - return this.employees; - } - - -} diff --git a/oop_employee_management/src/service/ValidatorService.java b/oop_employee_management/src/service/ValidatorService.java deleted file mode 100644 index 21e4996..0000000 --- a/oop_employee_management/src/service/ValidatorService.java +++ /dev/null @@ -1,27 +0,0 @@ -package service; - -import exception.BirthDayException; -import exception.EmailException; -import exception.FullNameException; -import exception.PhoneException; - -import java.time.LocalDate; - -public class ValidatorService { - - public static void birthdayCheck(LocalDate birthday) throws BirthDayException { - // TODO HERE - } - - public static void phoneCheck(String phone) throws PhoneException { - // TODO HERE - } - - public static void emailCheck(String email) throws EmailException { - // TODO HERE - } - - public static void nameCheck(String name) throws FullNameException { - // TODO HERE - } -} diff --git a/oop_employee_management/src/ui/ScannerFactory.java b/oop_employee_management/src/ui/ScannerFactory.java deleted file mode 100644 index 22e8137..0000000 --- a/oop_employee_management/src/ui/ScannerFactory.java +++ /dev/null @@ -1,15 +0,0 @@ -package ui; - -import java.util.Scanner; - -public class ScannerFactory { - - private static Scanner SCANNER; - - public static Scanner getScanner() { - if (SCANNER == null) { - SCANNER = new Scanner(System.in); - } - return SCANNER; - } -} diff --git a/oop_employee_management/src/ui/UIManager.java b/oop_employee_management/src/ui/UIManager.java deleted file mode 100644 index 44b323c..0000000 --- a/oop_employee_management/src/ui/UIManager.java +++ /dev/null @@ -1,113 +0,0 @@ -package ui; - -import entity.Employee; -import entity.Experience; -import entity.Fresher; -import entity.Intern; -import exception.BirthDayException; -import exception.EmailException; -import exception.FullNameException; -import exception.PhoneException; -import service.EmployeeManager; -import service.ValidatorService; - -import java.util.Scanner; - -public class UIManager { - - private EmployeeManager employeeManager = new EmployeeManager(); - - /** - * @param type - * @return Employee - * type = 0 => Experience - * type = 1 => Fresher - * type = 2 => Intern - */ - public void insert(int type) { - Employee employee = null; - if (type == 0) { - employee = insertExperience(); - } - if (type == 1) { - employee = insertFresher(); - } - if (type == 2) { - employee = insertIntern(); - } - - try { - checkData(employee); - } catch (BirthDayException e) { - // insert => insert(type); - insert(type); - } catch (PhoneException e) { - // insert => insert(type); - insert(type); - } catch (EmailException e) { - // insert => insert(type); - insert(type); - } catch (FullNameException e) { - // insert => insert(type); - insert(type); - } - - this.employeeManager.insert(employee); - } - - private Experience insertExperience() { - Experience experience = new Experience(); - Scanner scanner = ScannerFactory.getScanner(); - System.out.print("Input ID: "); - String id = scanner.nextLine(); - System.out.print("Input Name: "); - String name = scanner.nextLine(); - System.out.print("Input Phone: "); - String phone = scanner.nextLine(); - System.out.print("Input Email: "); - String email = scanner.nextLine(); - - // TODO - return experience; - } - - private Intern insertIntern() { - - Intern intern = new Intern(); - // TODO - return intern; - } - - private Fresher insertFresher() { - Fresher fresher = new Fresher(); - // TODO - return fresher; - } - - public void update() { - System.out.print("Input ID to update: "); - String id = ScannerFactory.getScanner().nextLine(); - Employee employee = this.employeeManager.findById(id); - // TODO HERE - } - - public void delete() { - System.out.print("Input ID to deleet: "); - String id = ScannerFactory.getScanner().nextLine(); - this.employeeManager.deleteById(id); - // TODO SHOW MESSAGE HERE - } - - public void showAllEmployee() { - this.employeeManager.findAll().forEach(Employee::showInformation); - } - - private void checkData(Employee employee) throws BirthDayException, PhoneException, EmailException, FullNameException { - ValidatorService.birthdayCheck(employee.getBirthday()); - ValidatorService.phoneCheck(employee.getPhone()); - ValidatorService.emailCheck(employee.getEmail()); - ValidatorService.nameCheck(employee.getFullName()); - } - - // TODO -} diff --git a/synthetic_exercise_oop_java/src/Main.java b/synthetic_exercise_oop_java/src/Main.java deleted file mode 100644 index 91ba70b..0000000 --- a/synthetic_exercise_oop_java/src/Main.java +++ /dev/null @@ -1,6 +0,0 @@ -public class Main { - - public static void main(String[] args) { - // You can run the exercise for earch package. In each package have Main class. - } -} diff --git a/synthetic_exercise_oop_java/src/b1/Engineer.java b/synthetic_exercise_oop_java/src/b1/Engineer.java deleted file mode 100644 index 62193ca..0000000 --- a/synthetic_exercise_oop_java/src/b1/Engineer.java +++ /dev/null @@ -1,30 +0,0 @@ -package b1; - -import java.time.LocalDate; - -public class Engineer extends Officer { - private String branch; - public Engineer(String name, int age, String gender, String address, String branch) { - super(name, age, gender, address); - this.branch = branch; - } - - public String getBranch() { - return branch; - } - - public void setBranch(String branch) { - this.branch = branch; - } - - @Override - public String toString() { - return "Engineer{" + - "branch='" + branch + '\'' + - ", name='" + name + '\'' + - ", age=" + age + - ", gender='" + gender + '\'' + - ", address='" + address + '\'' + - '}'; - } -} diff --git a/synthetic_exercise_oop_java/src/b1/Main.java b/synthetic_exercise_oop_java/src/b1/Main.java deleted file mode 100644 index d8fbe23..0000000 --- a/synthetic_exercise_oop_java/src/b1/Main.java +++ /dev/null @@ -1,106 +0,0 @@ -package b1; - -import java.util.Scanner; - -public class Main { - - public static void main(String[] args) { - Scanner scanner = new Scanner(System.in); - ManagerOfficer managerOfficer = new ManagerOfficer(); - while (true) { - System.out.println("Application Manager Officer"); - System.out.println("Enter 1: To insert officer"); - System.out.println("Enter 2: To search officer by name: "); - System.out.println("Enter 3: To show information officers"); - System.out.println("Enter 4: To exit:"); - String line = scanner.nextLine(); - switch (line) { - case "1": { - System.out.println("Enter a: to insert Enginner"); - System.out.println("Enter b: to insert Worker"); - System.out.println("Enter c: to insert Staff"); - String type = scanner.nextLine(); - switch (type) { - case "a": { - System.out.print("Enter name: "); - String name = scanner.nextLine(); - System.out.print("Enter age:"); - int age = scanner.nextInt(); - System.out.print("Enter gender: "); - scanner.nextLine(); - String gender = scanner.nextLine(); - System.out.print("Enter address: "); - String address = scanner.nextLine(); - System.out.print("Enter branch: "); - String branch = scanner.nextLine(); - Officer engineer = new Engineer(name, age, gender, address, branch); - managerOfficer.addOfficer(engineer); - System.out.println(engineer.toString()); - break; - - } - case "b": { - System.out.print("Enter name: "); - String name = scanner.nextLine(); - System.out.print("Enter age:"); - int age = scanner.nextInt(); - System.out.print("Enter gender: "); - scanner.nextLine(); - String gender = scanner.nextLine(); - System.out.print("Enter address: "); - String address = scanner.nextLine(); - System.out.print("Enter level: "); - int level = scanner.nextInt(); - Officer worker = new Worker(name, age, gender, address, level); - managerOfficer.addOfficer(worker); - System.out.println(worker.toString()); - scanner.nextLine(); - break; - } - case "c": { - System.out.print("Enter name: "); - String name = scanner.nextLine(); - System.out.print("Enter age: "); - int age = scanner.nextInt(); - System.out.print("Enter gender: "); - scanner.nextLine(); - String gender = scanner.nextLine(); - System.out.print("Enter address: "); - String address = scanner.nextLine(); - System.out.print("Enter task: "); - String task = scanner.nextLine(); - Officer staff = new Staff(name, age, gender, address, task); - managerOfficer.addOfficer(staff); - System.out.println(staff.toString()); - break; - } - default: - System.out.println("Invalid"); - break; - } - break; - } - case "2": { - System.out.print("Enter name to search: "); - String name = scanner.nextLine(); - managerOfficer.searchOfficerByName(name).forEach(officer -> { - System.out.println(officer.toString()); - }); - break; - } - case "3": { - managerOfficer.showListInforOfficer(); - break; - } - case "4": { - return; - } - default: - System.out.println("Invalid"); - continue; - } - - } - } - -} diff --git a/synthetic_exercise_oop_java/src/b1/ManagerOfficer.java b/synthetic_exercise_oop_java/src/b1/ManagerOfficer.java deleted file mode 100644 index 376edfe..0000000 --- a/synthetic_exercise_oop_java/src/b1/ManagerOfficer.java +++ /dev/null @@ -1,25 +0,0 @@ -package b1; - -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -public class ManagerOfficer { - private List officers; - - public ManagerOfficer() { - this.officers = new ArrayList<>(); - } - - public void addOfficer(Officer officer) { - this.officers.add(officer); - } - - public List searchOfficerByName(String name) { - return this.officers.stream().filter(o -> o.getName().contains(name)).collect(Collectors.toList()); - } - - public void showListInforOfficer() { - this.officers.forEach(o -> System.out.println(o.toString())); - } -} diff --git a/synthetic_exercise_oop_java/src/b1/Officer.java b/synthetic_exercise_oop_java/src/b1/Officer.java deleted file mode 100644 index 9b22132..0000000 --- a/synthetic_exercise_oop_java/src/b1/Officer.java +++ /dev/null @@ -1,49 +0,0 @@ -package b1; - -import java.time.LocalDate; - -public class Officer { - protected String name; - protected int age; - protected String gender; - protected String address; - - public Officer(String name, int age, String gender, String address) { - this.name = name; - this.age = age; - this.gender = gender; - this.address = address; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getAge() { - return age; - } - - public void setAge(int age) { - this.age = age; - } - - public String getGender() { - return gender; - } - - public void setGender(String gender) { - this.gender = gender; - } - - public String getAddress() { - return address; - } - - public void setAddress(String address) { - this.address = address; - } -} diff --git a/synthetic_exercise_oop_java/src/b1/Staff.java b/synthetic_exercise_oop_java/src/b1/Staff.java deleted file mode 100644 index af58bad..0000000 --- a/synthetic_exercise_oop_java/src/b1/Staff.java +++ /dev/null @@ -1,30 +0,0 @@ -package b1; - -import java.time.LocalDate; - -public class Staff extends Officer { - private String task; - public Staff(String name, int age, String gender, String address, String task) { - super(name, age, gender, address); - this.task = task; - } - - public String getTask() { - return task; - } - - public void setTask(String task) { - this.task = task; - } - - @Override - public String toString() { - return "Staff{" + - "task='" + task + '\'' + - ", name='" + name + '\'' + - ", age=" + age + - ", gender='" + gender + '\'' + - ", address='" + address + '\'' + - '}'; - } -} diff --git a/synthetic_exercise_oop_java/src/b1/Worker.java b/synthetic_exercise_oop_java/src/b1/Worker.java deleted file mode 100644 index 76aa86d..0000000 --- a/synthetic_exercise_oop_java/src/b1/Worker.java +++ /dev/null @@ -1,31 +0,0 @@ -package b1; - -import java.time.LocalDate; - -public class Worker extends Officer { - private int level; - - public Worker(String name, int age, String gender, String address, int level) { - super(name, age, gender, address); - this.level = level; - } - - public int getLevel() { - return level; - } - - public void setLevel(int level) { - this.level = level; - } - - @Override - public String toString() { - return "Worker{" + - "level=" + level + - ", name='" + name + '\'' + - ", age=" + age + - ", gender='" + gender + '\'' + - ", address='" + address + '\'' + - '}'; - } -} diff --git a/synthetic_exercise_oop_java/src/b2/Book.java b/synthetic_exercise_oop_java/src/b2/Book.java deleted file mode 100644 index 9c3afc1..0000000 --- a/synthetic_exercise_oop_java/src/b2/Book.java +++ /dev/null @@ -1,40 +0,0 @@ -package b2; - -public class Book extends Document { - private String author; - private int numerPage; - - - public Book(String id, String nxb, int number, String author, int numberPage) { - super(id, nxb, number); - this.author = author; - this.numerPage = numberPage; - } - - public String getAuthor() { - return author; - } - - public void setAuthor(String author) { - this.author = author; - } - - public int getNumerPage() { - return numerPage; - } - - public void setNumerPage(int numerPage) { - this.numerPage = numerPage; - } - - @Override - public String toString() { - return "Book{" + - "author='" + author + '\'' + - ", numerPage=" + numerPage + - ", id='" + id + '\'' + - ", nxb='" + nxb + '\'' + - ", number='" + number + '\'' + - '}'; - } -} diff --git a/synthetic_exercise_oop_java/src/b2/Document.java b/synthetic_exercise_oop_java/src/b2/Document.java deleted file mode 100644 index a6552e5..0000000 --- a/synthetic_exercise_oop_java/src/b2/Document.java +++ /dev/null @@ -1,37 +0,0 @@ -package b2; - -public class Document { - protected String id; - protected String nxb; - protected int number; - - public Document(String id, String nxb, int number) { - this.id = id; - this.nxb = nxb; - this.number = number; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getNxb() { - return nxb; - } - - public void setNxb(String nxb) { - this.nxb = nxb; - } - - public int getNumber() { - return number; - } - - public void setNumber(int number) { - this.number = number; - } -} diff --git a/synthetic_exercise_oop_java/src/b2/Journal.java b/synthetic_exercise_oop_java/src/b2/Journal.java deleted file mode 100644 index 56d2586..0000000 --- a/synthetic_exercise_oop_java/src/b2/Journal.java +++ /dev/null @@ -1,40 +0,0 @@ -package b2; - -public class Journal extends Document { - - private int issueNumber; - private int monthIssue; - - public Journal(String id, String nxb, int number, int issueNumber, int monthIssue) { - super(id, nxb, number); - this.issueNumber = issueNumber; - this.monthIssue = monthIssue; - } - - public int getIssueNumber() { - return issueNumber; - } - - public void setIssueNumber(int issueNumber) { - this.issueNumber = issueNumber; - } - - public int getMonthIssue() { - return monthIssue; - } - - public void setMonthIssue(int monthIssue) { - this.monthIssue = monthIssue; - } - - @Override - public String toString() { - return "Journal{" + - "issueNumber=" + issueNumber + - ", monthIssue=" + monthIssue + - ", id='" + id + '\'' + - ", nxb='" + nxb + '\'' + - ", number='" + number + '\'' + - '}'; - } -} diff --git a/synthetic_exercise_oop_java/src/b2/Main.java b/synthetic_exercise_oop_java/src/b2/Main.java deleted file mode 100644 index 88cf261..0000000 --- a/synthetic_exercise_oop_java/src/b2/Main.java +++ /dev/null @@ -1,127 +0,0 @@ -package b2; - -import b1.ManagerOfficer; - -import java.util.Scanner; - -public class Main { - - public static void main(String[] args) { - Scanner scanner = new Scanner(System.in); - ManagerDocument managerDocument = new ManagerDocument(); - while (true) { - System.out.println("Application Manager Document"); - System.out.println("Enter 1: To insert document"); - System.out.println("Enter 2: To search document by category: "); - System.out.println("Enter 3: To show information documents"); - System.out.println("Enter 4: To remove document by id"); - System.out.println("Enter 5: To exit:"); - String line = scanner.nextLine(); - switch (line) { - case "1": { - System.out.println("Enter a: to insert Book"); - System.out.println("Enter b: to insert Newspaper"); - System.out.println("Enter c: to insert Journal"); - String type = scanner.nextLine(); - switch (type) { - case "a": { - System.out.print("Enter ID: "); - String id = scanner.nextLine(); - System.out.print("Enter nxb:"); - String nxb = scanner.nextLine(); - System.out.print("Enter number: "); - int number = scanner.nextInt(); - System.out.print("Enter author: "); - scanner.nextLine(); - String author = scanner.nextLine(); - System.out.print("Enter page number: "); - int pageNumber = scanner.nextInt(); - Document book = new Book(id, nxb, number, author, pageNumber); - managerDocument.addDocument(book); - System.out.println(book.toString()); - scanner.nextLine(); - break; - - } - case "b": { - System.out.print("Enter ID: "); - String id = scanner.nextLine(); - System.out.print("Enter nxb:"); - String nxb = scanner.nextLine(); - System.out.print("Enter number: "); - int number = scanner.nextInt(); - System.out.print("Enter Day issue: "); - int dayIssue = scanner.nextInt(); - Document newspaper = new Newspaper(id, nxb, number, dayIssue); - managerDocument.addDocument(newspaper); - System.out.println(newspaper.toString()); - scanner.nextLine(); - break; - } - case "c": { - System.out.print("Enter ID: "); - String id = scanner.nextLine(); - System.out.print("Enter nxb:"); - String nxb = scanner.nextLine(); - System.out.print("Enter number: "); - int number = scanner.nextInt(); - System.out.print("Enter issue number : "); - int issueNumber = scanner.nextInt(); - System.out.print("Enter issue month : "); - int issueMonth = scanner.nextInt(); - Document journal = new Journal(id, nxb, number, issueNumber, issueMonth); - managerDocument.addDocument(journal); - System.out.println(journal.toString()); - scanner.nextLine(); - break; - } - default: - break; - } - break; - } - case "2": { - System.out.println("Enter a to search book"); - System.out.println("Enter b to search newspaper"); - System.out.println("Enter a to search journal"); - String choise = scanner.nextLine(); - switch (choise) { - case "a": { - managerDocument.searchByBook(); - break; - } - case "b": { - managerDocument.searchByNewspaper(); - break; - } - case "c": - managerDocument.searchByJournal(); - break; - default: - System.out.println("Invalid"); - break; - } - break; - } - case "3": { - managerDocument.showInfor(); - break; - } - case "4": { - System.out.print("Enter id to remove: "); - String id = scanner.nextLine(); - System.out.println(managerDocument.deleteDocument(id) ? "Success" : "Fail"); - } - break; - case "5": { - return; - } - default: - System.out.println("Invalid"); - continue; - } - - } - } - -} diff --git a/synthetic_exercise_oop_java/src/b2/ManagerDocument.java b/synthetic_exercise_oop_java/src/b2/ManagerDocument.java deleted file mode 100644 index 14d765a..0000000 --- a/synthetic_exercise_oop_java/src/b2/ManagerDocument.java +++ /dev/null @@ -1,43 +0,0 @@ -package b2; - -import java.util.ArrayList; -import java.util.List; - -public class ManagerDocument { - List documents; - - public ManagerDocument() { - this.documents = new ArrayList<>(); - } - - public void addDocument(Document document) { - this.documents.add(document); - } - - public boolean deleteDocument(String id) { - Document doc = this.documents.stream() - .filter(document -> document.getId().equals(id)) - .findFirst().orElse(null); - if (doc == null) { - return false; - } - this.documents.remove(doc); - return true; - } - - public void showInfor() { - this.documents.forEach(documents -> System.out.println(documents.toString())); - } - - public void searchByBook() { - this.documents.stream().filter(doc -> doc instanceof Book).forEach(doc -> System.out.println(doc.toString())); - } - - public void searchByNewspaper() { - this.documents.stream().filter(doc -> doc instanceof Newspaper).forEach(doc -> System.out.println(doc.toString())); - } - - public void searchByJournal() { - this.documents.stream().filter(doc -> doc instanceof Journal).forEach(doc -> System.out.println(doc.toString())); - } -} diff --git a/synthetic_exercise_oop_java/src/b2/Newspaper.java b/synthetic_exercise_oop_java/src/b2/Newspaper.java deleted file mode 100644 index 5f572d4..0000000 --- a/synthetic_exercise_oop_java/src/b2/Newspaper.java +++ /dev/null @@ -1,28 +0,0 @@ -package b2; - -public class Newspaper extends Document { - private int dayIssue; - - public Newspaper(String id, String nxb, int number, int dayIssue) { - super(id, nxb, number); - this.dayIssue = dayIssue; - } - - public int getDayIssue() { - return dayIssue; - } - - public void setDayIssue(int dayIssue) { - this.dayIssue = dayIssue; - } - - @Override - public String toString() { - return "Newspaper{" + - "dayIssue=" + dayIssue + - ", id='" + id + '\'' + - ", nxb='" + nxb + '\'' + - ", number='" + number + '\'' + - '}'; - } -} diff --git a/synthetic_exercise_oop_java/src/b3/Candidate.java b/synthetic_exercise_oop_java/src/b3/Candidate.java deleted file mode 100644 index ec5cb47..0000000 --- a/synthetic_exercise_oop_java/src/b3/Candidate.java +++ /dev/null @@ -1,47 +0,0 @@ -package b3; - -public class Candidate { - protected String id; - protected String name; - protected String address; - protected int priority; - - public Candidate(String id, String name, String address, int priority) { - this.id = id; - this.name = name; - this.address = address; - this.priority = priority; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getAddress() { - return address; - } - - public void setAddress(String address) { - this.address = address; - } - - public int getPriority() { - return priority; - } - - public void setPriority(int priority) { - this.priority = priority; - } -} diff --git a/synthetic_exercise_oop_java/src/b3/CandidateA.java b/synthetic_exercise_oop_java/src/b3/CandidateA.java deleted file mode 100644 index 6a2fcfa..0000000 --- a/synthetic_exercise_oop_java/src/b3/CandidateA.java +++ /dev/null @@ -1,20 +0,0 @@ -package b3; - -public class CandidateA extends Candidate { - public static final String MON_TOAN = "Toan"; - public static final String MON_LY = "Ly"; - public static final String MON_HOA = "Hoa"; - public CandidateA(String id, String name, String address, int priority) { - super(id, name, address, priority); - } - - @Override - public String toString() { - return "CandidateA{" + - "id='" + id + '\'' + - ", name='" + name + '\'' + - ", address='" + address + '\'' + - ", priority=" + priority + ", Subject: " + MON_TOAN + " - " + MON_LY + " - " + MON_HOA + - '}'; - } -} diff --git a/synthetic_exercise_oop_java/src/b3/CandidateB.java b/synthetic_exercise_oop_java/src/b3/CandidateB.java deleted file mode 100644 index 8afc14e..0000000 --- a/synthetic_exercise_oop_java/src/b3/CandidateB.java +++ /dev/null @@ -1,22 +0,0 @@ -package b3; - -public class CandidateB extends Candidate { - - public static final String MON_TOAN = "Toan"; - public static final String MON_HOA = "Hoa"; - public static final String MON_SINH = "Sinh"; - - public CandidateB(String id, String name, String address, int priority) { - super(id, name, address, priority); - } - - @Override - public String toString() { - return "CandidateB{" + - "id='" + id + '\'' + - ", name='" + name + '\'' + - ", address='" + address + '\'' + - ", priority=" + priority + ", Subject: " + MON_TOAN + " - " + MON_SINH + " - " + MON_HOA + - '}'; - } -} diff --git a/synthetic_exercise_oop_java/src/b3/CandidateC.java b/synthetic_exercise_oop_java/src/b3/CandidateC.java deleted file mode 100644 index 15242bb..0000000 --- a/synthetic_exercise_oop_java/src/b3/CandidateC.java +++ /dev/null @@ -1,22 +0,0 @@ -package b3; - -public class CandidateC extends Candidate { - - public static final String MON_VAN = "Van"; - public static final String MON_SU = "Su"; - public static final String MON_DIA = "Dia"; - - public CandidateC(String id, String name, String address, int priority) { - super(id, name, address, priority); - } - - @Override - public String toString() { - return "CandidateC{" + - "id='" + id + '\'' + - ", name='" + name + '\'' + - ", address='" + address + '\'' + - ", priority=" + priority + ", Subject: " + MON_VAN + " - " + MON_SU + " - " + MON_DIA + - '}'; - } -} diff --git a/synthetic_exercise_oop_java/src/b3/Main.java b/synthetic_exercise_oop_java/src/b3/Main.java deleted file mode 100644 index daa0aaf..0000000 --- a/synthetic_exercise_oop_java/src/b3/Main.java +++ /dev/null @@ -1,88 +0,0 @@ -package b3; - -import java.util.Scanner; - -public class Main { - - public static void main(String[] args) { - Scanner scanner = new Scanner(System.in); - ManagerCandidate managerCandidate = new ManagerCandidate(); - while (true) { - System.out.println("Application Manager Candidate"); - System.out.println("Enter 1: To insert candidate"); - System.out.println("Enter 2: To show information of candidate: "); - System.out.println("Enter 3: To search candidate by id"); - System.out.println("Enter 4: To exit:"); - String line = scanner.nextLine(); - switch (line) { - case "1": { - System.out.println("Enter a: to insert Candidate A"); - System.out.println("Enter b: to insert Candidate B"); - System.out.println("Enter c: to insert Candidate C"); - String type = scanner.nextLine(); - switch (type) { - case "a": { - managerCandidate.add(createCadidate(scanner, "a")); - break; - - } - case "b": { - managerCandidate.add(createCadidate(scanner, "b")); - break; - } - case "c": { - managerCandidate.add(createCadidate(scanner, "c")); - break; - } - default: - System.out.println("Invalid"); - break; - } - break; - } - case "2": { - managerCandidate.showInfor(); - break; - } - case "3": { - System.out.print("Enter ID: "); - String id = scanner.nextLine(); - Candidate candidate = managerCandidate.searchById(id); - if (candidate == null) { - System.out.println("Not found"); - } else { - System.out.println(candidate.toString()); - } - break; - } - case "4": { - return; - } - default: - System.out.println("Invalid"); - continue; - } - - } - } - - public static Candidate createCadidate(Scanner scanner, String cate) { - System.out.print("Enter ID: "); - String id = scanner.nextLine(); - System.out.print("Enter name: "); - String name = scanner.nextLine(); - System.out.print("Enter address: "); - String address = scanner.nextLine(); - System.out.print("Enter Priotity: "); - int priority = scanner.nextInt(); - scanner.nextLine(); - if (cate.equals("a")) { - return new CandidateA(id, name,address,priority); - } else if (cate.equals("b")) { - return new CandidateB(id, name,address,priority); - } else { - return new CandidateC(id, name,address,priority); - } - - } -} diff --git a/synthetic_exercise_oop_java/src/b3/ManagerCandidate.java b/synthetic_exercise_oop_java/src/b3/ManagerCandidate.java deleted file mode 100644 index 7ed3d96..0000000 --- a/synthetic_exercise_oop_java/src/b3/ManagerCandidate.java +++ /dev/null @@ -1,25 +0,0 @@ -package b3; - -import java.util.ArrayList; -import java.util.List; - -public class ManagerCandidate { - List candidates; - public ManagerCandidate() { - this.candidates = new ArrayList<>(); - } - - public void add(Candidate candidate) { - this.candidates.add(candidate); - } - - public void showInfor() { - this.candidates.forEach(candidate -> System.out.println(candidate.toString())); - } - - public Candidate searchById(String id) { - return this.candidates.stream().filter(candidate -> candidate.getId().equals(id)).findFirst().orElse(null); - } - - -} diff --git a/synthetic_exercise_oop_java/src/b4/Family.java b/synthetic_exercise_oop_java/src/b4/Family.java deleted file mode 100644 index 72aa52f..0000000 --- a/synthetic_exercise_oop_java/src/b4/Family.java +++ /dev/null @@ -1,37 +0,0 @@ -package b4; - -import java.util.List; - -public class Family { - private List presons; - private String address; - - public Family(List presons, String address) { - this.presons = presons; - this.address = address; - } - - public List getPresons() { - return presons; - } - - public void setPresons(List presons) { - this.presons = presons; - } - - public String getAddress() { - return address; - } - - public void setAddress(String address) { - this.address = address; - } - - @Override - public String toString() { - return "Family{" + - "presons=" + presons + - ", address='" + address + '\'' + - '}'; - } -} diff --git a/synthetic_exercise_oop_java/src/b4/Main.java b/synthetic_exercise_oop_java/src/b4/Main.java deleted file mode 100644 index 382ba01..0000000 --- a/synthetic_exercise_oop_java/src/b4/Main.java +++ /dev/null @@ -1,38 +0,0 @@ -package b4; - -import java.util.ArrayList; -import java.util.List; -import java.util.Scanner; - -// This is sudo code. To overview how to do it. -// You can finish by fill you code - -public class Main { - public static void main(String[] args) { - Town town = new Town(); - Scanner scanner = new Scanner(System.in); - System.out.println("Enter n:"); - int n = scanner.nextInt(); - for(int i = 0; i < n; i++) { - // Input foreach famili - - System.out.println("Enter address:"); - scanner.nextLine(); - String address = scanner.nextLine(); - - // Enter person number in family - List persons = new ArrayList<>(); - System.out.println("Enter number person"); - int number = scanner.nextInt(); - - for (int j = 0; j < number; j++) { - // Inout person for family - } - - // After done input - town.addFamily(new Family(persons,address )); - - - } - } -} diff --git a/synthetic_exercise_oop_java/src/b4/Person.java b/synthetic_exercise_oop_java/src/b4/Person.java deleted file mode 100644 index 057a494..0000000 --- a/synthetic_exercise_oop_java/src/b4/Person.java +++ /dev/null @@ -1,58 +0,0 @@ -package b4; - -public class Person { - private String name; - private int age; - private String job; - private String passport; - - public Person(String name, int age, String job, String passport) { - this.name = name; - this.age = age; - this.job = job; - this.passport = passport; - } - - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getAge() { - return age; - } - - public void setAge(int age) { - this.age = age; - } - - public String getJob() { - return job; - } - - public void setJob(String job) { - this.job = job; - } - - public String getPassport() { - return passport; - } - - public void setPassport(String passport) { - this.passport = passport; - } - - @Override - public String toString() { - return "Person{" + - "name='" + name + '\'' + - ", age=" + age + - ", job='" + job + '\'' + - ", passport='" + passport + '\'' + - '}'; - } -} diff --git a/synthetic_exercise_oop_java/src/b4/Town.java b/synthetic_exercise_oop_java/src/b4/Town.java deleted file mode 100644 index 82b3ee8..0000000 --- a/synthetic_exercise_oop_java/src/b4/Town.java +++ /dev/null @@ -1,24 +0,0 @@ -package b4; - -import java.util.ArrayList; -import java.util.List; - -public class Town { - List families; - - public Town() { - this.families = new ArrayList<>(); - } - - public List getFamilies() { - return families; - } - - public void setFamilies(List families) { - this.families = families; - } - - public void addFamily(Family family) { - this.families.add(family); - } -} diff --git a/synthetic_exercise_oop_java/src/b5/Hotel.java b/synthetic_exercise_oop_java/src/b5/Hotel.java deleted file mode 100644 index 42b9317..0000000 --- a/synthetic_exercise_oop_java/src/b5/Hotel.java +++ /dev/null @@ -1,38 +0,0 @@ -package b5; - -import java.util.ArrayList; -import java.util.List; - -public class Hotel { - private List persons; - - public Hotel() { - persons = new ArrayList<>(); - } - - public void add(Person person) { - this.persons.add(person); - } - - public boolean delete(String passport) { - Person person = this.persons.stream().filter(p -> p.getPassport().equals(passport)).findFirst().orElse(null); - if (person == null) { - return false; - } else { - this.persons.remove(person); - return true; - } - } - - public int calculator(String passport) { - Person person = this.persons.stream().filter(p -> p.getPassport().equals(passport)).findFirst().orElse(null); - if (person == null) { - return 0; - } - return person.getRoom().getPrice() * person.getNumberRent(); - } - - public void show() { - this.persons.forEach(p -> System.out.println(p.toString())); - } -} diff --git a/synthetic_exercise_oop_java/src/b5/Main.java b/synthetic_exercise_oop_java/src/b5/Main.java deleted file mode 100644 index 47c259f..0000000 --- a/synthetic_exercise_oop_java/src/b5/Main.java +++ /dev/null @@ -1,73 +0,0 @@ -package b5; - -import java.util.Scanner; - -public class Main { - public static void main(String[] args) { - Scanner scanner = new Scanner(System.in); - Hotel hotel = new Hotel(); - while (true) { - System.out.println("Application Manager Candidate"); - System.out.println("Enter 1: To insert person for rent"); - System.out.println("Enter 2: To remove person by passport"); - System.out.println("Enter 3: To calculator price by passport"); - System.out.println("Enter 4: To show infor"); - System.out.println("Enter 5: To exit:"); - String line = scanner.nextLine(); - switch(line) { - case "1": { - System.out.print("Enter name: "); - String name = scanner.nextLine(); - System.out.print("Enter age: "); - int age = scanner.nextInt(); - System.out.print("Enter passport: "); - scanner.nextLine(); - String passport = scanner.nextLine(); - System.out.println("Choise a to rent room type A"); - System.out.println("Choise b to rent room type B"); - System.out.println("Choise c to rent room type C"); - String choise = scanner.nextLine(); - Room room; - if (choise.equals("a")) { - room = new RoomA(); - } else if (choise.equals("b")) { - room = new RoomB(); - } else if (choise.equals("c")) { - room = new RoomC(); - } else { - continue; - } - System.out.print("Enter number day for rent: "); - int numberRent = scanner.nextInt(); - Person person = new Person(name, age, passport, room, numberRent); - hotel.add(person); - scanner.nextLine(); - break; - } - case "2": { - System.out.print("Enter passport: "); - String passport = scanner.nextLine(); - hotel.delete(passport); - break; - } - case "3": { - System.out.print("Enter passport: "); - String passport = scanner.nextLine(); - System.out.println("Price: " + hotel.calculator(passport)); - break; - } - case "4": { - hotel.show(); - break; - } - case "5": { - return; - } - default: - System.out.println("Invalid"); - continue; - } - } - - } -} diff --git a/synthetic_exercise_oop_java/src/b5/Person.java b/synthetic_exercise_oop_java/src/b5/Person.java deleted file mode 100644 index 1f85bac..0000000 --- a/synthetic_exercise_oop_java/src/b5/Person.java +++ /dev/null @@ -1,66 +0,0 @@ -package b5; - -public class Person { - private String name; - private int age; - private String passport; - private Room room; - private int numberRent; - - public Person(String name, int age, String passport, Room room, int numberRent) { - this.name = name; - this.age = age; - this.passport = passport; - this.numberRent = numberRent; - this.room = room; - } - - public int getNumberRent() { - return numberRent; - } - - public void setNumberRent(int numberRent) { - this.numberRent = numberRent; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getAge() { - return age; - } - - public void setAge(int age) { - this.age = age; - } - - public String getPassport() { - return passport; - } - - public void setPassport(String passport) { - this.passport = passport; - } - - public Room getRoom() { - return room; - } - - public void setRoom(Room room) { - this.room = room; - } - - @Override - public String toString() { - return "Person{" + - "name='" + name + '\'' + - ", age=" + age + - ", passport='" + passport + '\'' + room.toString() + - '}'; - } -} diff --git a/synthetic_exercise_oop_java/src/b5/Room.java b/synthetic_exercise_oop_java/src/b5/Room.java deleted file mode 100644 index 3d761a2..0000000 --- a/synthetic_exercise_oop_java/src/b5/Room.java +++ /dev/null @@ -1,27 +0,0 @@ -package b5; - -public class Room { - protected String category; - protected int price; - - public Room(String category, int price) { - this.category = category; - this.price = price; - } - - public String getCategory() { - return category; - } - - public void setCategory(String category) { - this.category = category; - } - - public int getPrice() { - return price; - } - - public void setPrice(int price) { - this.price = price; - } -} diff --git a/synthetic_exercise_oop_java/src/b5/RoomA.java b/synthetic_exercise_oop_java/src/b5/RoomA.java deleted file mode 100644 index 5157f66..0000000 --- a/synthetic_exercise_oop_java/src/b5/RoomA.java +++ /dev/null @@ -1,16 +0,0 @@ -package b5; - -public class RoomA extends Room { - - public RoomA() { - super("A", 500); - } - - @Override - public String toString() { - return "RoomA{" + - "category='" + category + '\'' + - ", price=" + price + - '}'; - } -} diff --git a/synthetic_exercise_oop_java/src/b5/RoomB.java b/synthetic_exercise_oop_java/src/b5/RoomB.java deleted file mode 100644 index fcb01d2..0000000 --- a/synthetic_exercise_oop_java/src/b5/RoomB.java +++ /dev/null @@ -1,15 +0,0 @@ -package b5; - -public class RoomB extends Room { - public RoomB() { - super("B", 300); - } - - @Override - public String toString() { - return "RoomB{" + - "category='" + category + '\'' + - ", price=" + price + - '}'; - } -} diff --git a/synthetic_exercise_oop_java/src/b5/RoomC.java b/synthetic_exercise_oop_java/src/b5/RoomC.java deleted file mode 100644 index 48f7c53..0000000 --- a/synthetic_exercise_oop_java/src/b5/RoomC.java +++ /dev/null @@ -1,15 +0,0 @@ -package b5; - -public class RoomC extends Room { - public RoomC() { - super("C", 100); - } - - @Override - public String toString() { - return "RoomC{" + - "category='" + category + '\'' + - ", price=" + price + - '}'; - } -} diff --git a/synthetic_exercise_oop_java/src/b6/Main.java b/synthetic_exercise_oop_java/src/b6/Main.java deleted file mode 100644 index 594ac5a..0000000 --- a/synthetic_exercise_oop_java/src/b6/Main.java +++ /dev/null @@ -1,17 +0,0 @@ -package b6; - -import java.util.Scanner; - -public class Main { - public static void main(String[] args) { - Scanner scanner = new Scanner(System.in); - - School school = new School(); - - // add Student to school by func add(). for ex: school.add(new Student(// infor); - - school.getStudent20YearOld(); - - school.countStudent23YearOldInDN(); - } -} diff --git a/synthetic_exercise_oop_java/src/b6/School.java b/synthetic_exercise_oop_java/src/b6/School.java deleted file mode 100644 index 9a91a34..0000000 --- a/synthetic_exercise_oop_java/src/b6/School.java +++ /dev/null @@ -1,25 +0,0 @@ -package b6; - -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -public class School { - private List students; - - public School() { - this.students = new ArrayList<>(); - } - - public void add(Student student) { - this.students.add(student); - } - - public List getStudent20YearOld() { - return this.students.stream().filter(student -> student.getAge() == 20).collect(Collectors.toList()); - } - - public long countStudent23YearOldInDN() { - return this.students.stream().filter(student -> student.getAge() == 23 && student.getHometown().equals("DN")).count(); - } -} diff --git a/synthetic_exercise_oop_java/src/b6/Student.java b/synthetic_exercise_oop_java/src/b6/Student.java deleted file mode 100644 index c1c6650..0000000 --- a/synthetic_exercise_oop_java/src/b6/Student.java +++ /dev/null @@ -1,56 +0,0 @@ -package b6; - -public class Student { - private String name; - private int age; - private String hometown; - private int classStudent; - - public Student(String name, int age, String hometown, int classStudent) { - this.name = name; - this.age = age; - this.hometown = hometown; - this.classStudent = classStudent; - } - - public int getClassStudent() { - return classStudent; - } - - public void setClassStudent(int classStudent) { - this.classStudent = classStudent; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getAge() { - return age; - } - - public void setAge(int age) { - this.age = age; - } - - public String getHometown() { - return hometown; - } - - public void setHometown(String hometown) { - this.hometown = hometown; - } - - @Override - public String toString() { - return "Student{" + - "name='" + name + '\'' + - ", age=" + age + - ", hometown='" + hometown + '\'' + - '}'; - } -} diff --git a/synthetic_exercise_oop_java/src/b7/Main.java b/synthetic_exercise_oop_java/src/b7/Main.java deleted file mode 100644 index b3668df..0000000 --- a/synthetic_exercise_oop_java/src/b7/Main.java +++ /dev/null @@ -1,19 +0,0 @@ -package b7; - -import java.util.Scanner; - -public class Main { - public static void main(String[] args) { - Scanner scanner = new Scanner(System.in); - ManagerTeacher managerTeacher = new ManagerTeacher(); - while (true) { - // show input for user choise - // 1 to insert - // 2 to remove => input id. output boolean - // 4 get salary => input id. output double - // 5 exit => return - - } - } - -} diff --git a/synthetic_exercise_oop_java/src/b7/ManagerTeacher.java b/synthetic_exercise_oop_java/src/b7/ManagerTeacher.java deleted file mode 100644 index 5ee02e7..0000000 --- a/synthetic_exercise_oop_java/src/b7/ManagerTeacher.java +++ /dev/null @@ -1,33 +0,0 @@ -package b7; - -import java.util.ArrayList; -import java.util.List; - -public class ManagerTeacher { - private List teachers; - - public ManagerTeacher() { - this.teachers = new ArrayList<>(); - } - - public void add(Teacher teacher) { - this.teachers.add(teacher); - } - - public boolean deleteById(String id) { - Teacher teacher = this.teachers.stream().filter(t -> t.getId().equals(id)).findFirst().orElse(null); - if (teacher == null) { - return false; - } - this.teachers.remove(teacher); - return true; - } - - public double getSalary(String id) { - Teacher teacher = this.teachers.stream().filter(t -> t.getId().equals(id)).findFirst().orElse(null); - if (teacher == null) { - return 0; - } - return teacher.getSalary() + teacher.getBonus() + teacher.getPenaty(); - } -} diff --git a/synthetic_exercise_oop_java/src/b7/Teacher.java b/synthetic_exercise_oop_java/src/b7/Teacher.java deleted file mode 100644 index a3cc9d3..0000000 --- a/synthetic_exercise_oop_java/src/b7/Teacher.java +++ /dev/null @@ -1,88 +0,0 @@ -package b7; - -public class Teacher { - private double salary; - private double bonus; - private double penaty; - private double realSalary; - private String name; - private int age; - private String hometown; - private String id; - - - public Teacher(double salary, double bonus, double penaty, double realSalary, String name, int age, String hometown, String id) { - this.salary = salary; - this.bonus = bonus; - this.penaty = penaty; - this.realSalary = realSalary; - this.name = name; - this.age = age; - this.hometown = hometown; - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getAge() { - return age; - } - - public void setAge(int age) { - this.age = age; - } - - public String getHometown() { - return hometown; - } - - public void setHometown(String hometown) { - this.hometown = hometown; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public double getSalary() { - return salary; - } - - public void setSalary(double salary) { - this.salary = salary; - } - - public double getBonus() { - return bonus; - } - - public void setBonus(double bonus) { - this.bonus = bonus; - } - - public double getPenaty() { - return penaty; - } - - public void setPenaty(double penaty) { - this.penaty = penaty; - } - - public double getRealSalary() { - return realSalary; - } - - public void setRealSalary(double realSalary) { - this.realSalary = realSalary; - } -} diff --git a/synthetic_exercise_oop_java/src/b8/Card.java b/synthetic_exercise_oop_java/src/b8/Card.java deleted file mode 100644 index 7bf14c1..0000000 --- a/synthetic_exercise_oop_java/src/b8/Card.java +++ /dev/null @@ -1,57 +0,0 @@ -package b8; - -public class Card { - private Student student; - private String id; - private int borrowDate; - private int paymentDate; - private int bookId; - - public Card(Student student, String id, int borrowDate, int paymentDate, int bookId) { - this.student = student; - this.id = id; - this.borrowDate = borrowDate; - this.paymentDate = paymentDate; - this.bookId = bookId; - } - - public Student getStudent() { - return student; - } - - public void setStudent(Student student) { - this.student = student; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public int getBorrowDate() { - return borrowDate; - } - - public void setBorrowDate(int borrowDate) { - this.borrowDate = borrowDate; - } - - public int getPaymentDate() { - return paymentDate; - } - - public void setPaymentDate(int paymentDate) { - this.paymentDate = paymentDate; - } - - public int getBookId() { - return bookId; - } - - public void setBookId(int bookId) { - this.bookId = bookId; - } -} diff --git a/synthetic_exercise_oop_java/src/b8/Main.java b/synthetic_exercise_oop_java/src/b8/Main.java deleted file mode 100644 index a0106a3..0000000 --- a/synthetic_exercise_oop_java/src/b8/Main.java +++ /dev/null @@ -1,18 +0,0 @@ -package b8; - -import java.util.Scanner; - -public class Main { - public static void main(String[] args) { - Scanner scanner = new Scanner(System.in); - ManagerCard managerCard = new ManagerCard(); - while (true) { - // show input for user choise - // 1 to insert - // 2 to remove => input id. output boolean - // 4 get salary => input id. output double - // 5 exit => return - - } - } -} diff --git a/synthetic_exercise_oop_java/src/b8/ManagerCard.java b/synthetic_exercise_oop_java/src/b8/ManagerCard.java deleted file mode 100644 index f9aec48..0000000 --- a/synthetic_exercise_oop_java/src/b8/ManagerCard.java +++ /dev/null @@ -1,26 +0,0 @@ -package b8; - -import java.util.ArrayList; -import java.util.List; - -public class ManagerCard { - - private List cards; - - public ManagerCard() { - this.cards = new ArrayList<>(); - } - - public void add(Card card) { - this.cards.add(card); - } - - public boolean delete(String id) { - Card card = this.cards.stream().filter(t -> t.getId().equals(id)).findFirst().orElse(null); - if (card == null) { - return false; - } - this.cards.remove(card); - return true; - } -} diff --git a/synthetic_exercise_oop_java/src/b8/Student.java b/synthetic_exercise_oop_java/src/b8/Student.java deleted file mode 100644 index c01e5fe..0000000 --- a/synthetic_exercise_oop_java/src/b8/Student.java +++ /dev/null @@ -1,37 +0,0 @@ -package b8; - -public class Student { - private String name; - private int age; - private String school; - - public Student(String name, int age, String school) { - this.name = name; - this.age = age; - this.school = school; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getAge() { - return age; - } - - public void setAge(int age) { - this.age = age; - } - - public String getSchool() { - return school; - } - - public void setSchool(String school) { - this.school = school; - } -} diff --git a/synthetic_exercise_oop_java/synthetic_exercise_oop_java.iml b/synthetic_exercise_oop_java/synthetic_exercise_oop_java.iml deleted file mode 100644 index c90834f..0000000 --- a/synthetic_exercise_oop_java/synthetic_exercise_oop_java.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file