Skip to content

Commit

Permalink
Added Section 5 Project
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohaned Yossry Abdulaziz committed Nov 25, 2020
1 parent 277acce commit 3bf16b9
Show file tree
Hide file tree
Showing 10 changed files with 131 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)






Expand Down
8 changes: 8 additions & 0 deletions Section5/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Section5/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Section5/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Section5/Section5.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
Binary file not shown.
Binary file added Section5/out/production/Group1Section5/Circle.class
Binary file not shown.
Binary file not shown.
Binary file added Section5/out/production/Group1Section5/Student.class
Binary file not shown.
76 changes: 76 additions & 0 deletions Section5/src/Section5.java
Original file line number Diff line number Diff line change
@@ -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() {

}
}

0 comments on commit 3bf16b9

Please sign in to comment.