From 3bf16b9f8cffd2cf5575a72235ae03f1998c15f1 Mon Sep 17 00:00:00 2001 From: Mohaned Yossry Abdulaziz Date: Wed, 25 Nov 2020 23:52:09 +0200 Subject: [PATCH] Added Section 5 Project --- README.md | 22 +++++ Section5/.idea/.gitignore | 8 ++ Section5/.idea/misc.xml | 6 ++ Section5/.idea/modules.xml | 8 ++ Section5/Section5.iml | 11 +++ .../Group1Section5/BankAccount.class | Bin 0 -> 1173 bytes .../production/Group1Section5/Circle.class | Bin 0 -> 452 bytes .../production/Group1Section5/Section5.class | Bin 0 -> 595 bytes .../production/Group1Section5/Student.class | Bin 0 -> 469 bytes Section5/src/Section5.java | 76 ++++++++++++++++++ 10 files changed, 131 insertions(+) create mode 100644 Section5/.idea/.gitignore create mode 100644 Section5/.idea/misc.xml create mode 100644 Section5/.idea/modules.xml create mode 100644 Section5/Section5.iml create mode 100644 Section5/out/production/Group1Section5/BankAccount.class create mode 100644 Section5/out/production/Group1Section5/Circle.class create mode 100644 Section5/out/production/Group1Section5/Section5.class create mode 100644 Section5/out/production/Group1Section5/Student.class create mode 100644 Section5/src/Section5.java 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 0000000000000000000000000000000000000000..26cc9fcf32693b286f07de12781166569fa4e6f4 GIT binary patch literal 1173 zcmaKqSx*yD6vzL!EuFSZ2W-nG)eb1ORG}{521u-gxYQ-7A>r|MW`qmVnWmjW_$0ph z%CkmGqKO~C4`n=eW+-5d4|C6*v;EF;fBpXc6TlMIQ_wJ%L>f1eD58|WduL#(thzeVDiYf{dUnsBVZ?>%qWq{-A=gWFrYE#!Zw zjCs4FLy2ou?(9DeN+6IXa|&)(PfJW33UAkJ^FspirYw|#>K-@tU-MR&OEImM+Yw~Z zOwnoC{HPxuEy>bSb+_9#tW6=yN!KmI6RxwoC>vEVhFKLO7*(*OVj1_Tg%{2Nw}q*P zX%swA@eq$F|EcA)l!?EGRqcvkjw9Q|)Ehw``kJodF;?WUs$vZ^w&8P~GmM@kdfV8e z3NNVYM;*^OT}XZnj^l1|OHWGNztB*jdTZk%l7jmwxODQ|hAFuGmo=M)(7BMZgy zS42L3g7yW`Ost2YW2DPcSKJ9fQ6H4?i<%_J6rrYZm6Dyo3Vm3CED}~ATnv$1lBC|p zeh9JoqDIWo0Avv87{juFI29n9JI~Y+#|*N#M%1};%zU4jzsSrglwk(5;rL!r9e(o! r_yJ}61c^+tN7JMxdl>FP4WYqAQ~vZyG_!dhrUt?0)}#egWuU!-0jGjRmY&r}pN@<}KB|eYEyyYwsoFUU_(rlCK#2JN2jdq}kfhJ1S|2qaiA6$Tq_9Mc6uSt}I3V`{Up)!`8-hk@0Hu_KIzV__Y6Ix9oK4?= qN-94hq>mv;6BVoymq7?w`XQuiYBU+kSRoWanmW?t%dke+hxK2~$ZM+r literal 0 HcmV?d00001 diff --git a/Section5/out/production/Group1Section5/Student.class b/Section5/out/production/Group1Section5/Student.class new file mode 100644 index 0000000000000000000000000000000000000000..cda48149bb797c65cd567adfbf17c47fd0227c55 GIT binary patch literal 469 zcmah^xlY4C6rATACLxdz?v9c}iW{gn8l*^|2nwSVbnAFA8@aYDkKU%fR93q zEenu9qS!a@n3?zX{p0lwz#+Dqs9?j#rjIQ_)vBo$bO&SgsDg>INf5fs*yLE?nOGnf zf{IGWsVCaTI%DgW#fh=TopH9iH>AyZ8k5o<7^|=5(@1AGDw-6==}1k6Dl>UqHmmO5 z%mj@==;pDuj=LIBrq#opnmIvj#`cq-8K(1Wr28f}S_<{ZnbaQj@=IG-L`&e827=D_ z{nyc$RP4axM}cbbYK%Y~et`=mHqd09vuFn{VHOaDSlfSrJTvjI%vdj)r)V?JsU)C- h6(Z365+AV2XTOB~A3|PR3RnLZUj88ztZ|2j^-m$XMpOU* literal 0 HcmV?d00001 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() { + + } +}