diff --git a/README.md b/README.md index 62d48ef..1da4593 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,28 @@ This repository will contain all materials used throughout the OS course 20/21 • [2D-Arrays](https://www.programiz.com/java-programming/multidimensional-array) +### 📖 Section 5 - Introduction to OOP, Classes and Objects. +------- +• [🎞 Section Presentation](https://drive.google.com/file/d/1U5_Xnv31veCmgiDudLDxIrAF2JSrurjr/view?usp=sharing) + +• [Java OOP - w3schools](https://www.w3schools.com/java/java_oop.asp) + +• [Java OOP - freecodecamp](https://www.freecodecamp.org/news/java-object-oriented-programming-system-principles-oops-concepts-for-beginners/) + +• [Java Classes and Objects - w3schools](https://www.w3schools.com/java/java_classes.asp) + +• [Java Classes and Objects - programiz](https://www.programiz.com/java-programming/class-objects) + +• [Java Classes and Objects - javatpoint](https://www.javatpoint.com/object-and-class-in-java) + +• [Class Attributes - w3schools](https://www.w3schools.com/java/java_class_attributes.asp) + +• [Class Methods - w3schools](https://www.w3schools.com/java/java_class_methods.asp) + +• [Java Constructors - javatpoint](https://www.javatpoint.com/java-constructor) + + + diff --git a/Section5/.idea/.gitignore b/Section5/.idea/.gitignore new file mode 100644 index 0000000..ca77080 --- /dev/null +++ b/Section5/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/../../../../:\WorkProjects\Group1Section5\.idea/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/Section5/.idea/misc.xml b/Section5/.idea/misc.xml new file mode 100644 index 0000000..0548357 --- /dev/null +++ b/Section5/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Section5/.idea/modules.xml b/Section5/.idea/modules.xml new file mode 100644 index 0000000..94ca371 --- /dev/null +++ b/Section5/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Section5/Section5.iml b/Section5/Section5.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/Section5/Section5.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Section5/out/production/Group1Section5/BankAccount.class b/Section5/out/production/Group1Section5/BankAccount.class new file mode 100644 index 0000000..26cc9fc Binary files /dev/null and b/Section5/out/production/Group1Section5/BankAccount.class differ diff --git a/Section5/out/production/Group1Section5/Circle.class b/Section5/out/production/Group1Section5/Circle.class new file mode 100644 index 0000000..1a2e53f Binary files /dev/null and b/Section5/out/production/Group1Section5/Circle.class differ diff --git a/Section5/out/production/Group1Section5/Section5.class b/Section5/out/production/Group1Section5/Section5.class new file mode 100644 index 0000000..a34956d Binary files /dev/null and b/Section5/out/production/Group1Section5/Section5.class differ diff --git a/Section5/out/production/Group1Section5/Student.class b/Section5/out/production/Group1Section5/Student.class new file mode 100644 index 0000000..cda4814 Binary files /dev/null and b/Section5/out/production/Group1Section5/Student.class differ diff --git a/Section5/src/Section5.java b/Section5/src/Section5.java new file mode 100644 index 0000000..94fb8cd --- /dev/null +++ b/Section5/src/Section5.java @@ -0,0 +1,76 @@ +public class Section5 { + public static void main(String[] args) { + BankAccount myAccount = new BankAccount(100); + myAccount.displayBalance(); + myAccount.deposit(1000); + myAccount.displayBalance(); + myAccount.withdraw(300); + myAccount.displayBalance(); + + } + +} + +class BankAccount { + double balance; + String accountHolder; + long accountNumber; + String password; + + BankAccount(double initialBalance){ + balance = initialBalance; + } + + void withdraw(double amount) { + if (amount > balance) { + System.out.println("Invalid Balance"); + } else { + balance = balance - amount; + } + } + + void deposit(double amount) { + if (amount > 0) { + balance = balance + amount; + } else { + System.out.println("Invalid amount"); + } + } + + void displayBalance() { + System.out.println("Your balance = " + balance); + } +} + + +class Circle { + double radius; + + // + Circle(double initialRadius) { + radius = initialRadius; + + } + + double calculateCircleArea() { + double area = 3.14 * radius * radius; + return area; + } +} + + +class Student { + String name; + int id; + + int age; + boolean gender; + + void breakfast() { + + } + + void study() { + + } +}