|
2 | 2 |
|
3 | 3 |  |
4 | 4 |
|
5 | | - |
6 | | - |
7 | | - |
8 | 5 | This repository contains Java programs demonstrating fundamental Object-Oriented Programming (OOP) concepts such as encapsulation, inheritance, and basic class design. It includes four tasks (1.1 to 1.4), each illustrating a different OOP principle. |
9 | 6 |
|
10 | | ---- |
11 | | - |
12 | 7 | ## 📁 Project Structure |
13 | | - |
14 | 8 | ``` |
15 | 9 | src/ |
16 | 10 | ├── Account.java |
17 | 11 | ├── Person.java |
18 | 12 | ├── Person_2.java |
19 | 13 | ├── Product.java |
20 | 14 | ├── XYZ.java |
21 | | -├── screenshots/ |
22 | | -│ ├── 1.1.png |
23 | | -│ ├── 1.2.a.png |
24 | | -│ ├── 1.2.b.png |
25 | | -│ ├── 1.3.png |
26 | | -│ └── 1.4.png |
27 | | -└── README.md |
28 | | -└── LICENSE |
| 15 | +└── screenshots/ |
| 16 | + ├── 1.1.png |
| 17 | + ├── 1.2.a.png |
| 18 | + ├── 1.2.b.png |
| 19 | + ├── 1.3.png |
| 20 | + └── 1.4.png |
29 | 21 | ``` |
30 | 22 |
|
31 | | ---- |
32 | | - |
33 | | -## 📝 Tasks Overview |
| 23 | +## 📝 Task Overviews |
34 | 24 |
|
35 | | -### **Task 1.1 – Person Class** |
| 25 | +### **Task 1.1 — Person Class** |
36 | 26 | - Implements a `Person` class with `name` and `age`. |
37 | | -- Default age is set to **18**. |
38 | | -- Uses constructors and a display method. |
| 27 | +- Default age is **18**. |
| 28 | +- Includes constructor + method to display info. |
39 | 29 |
|
40 | | -📸 **Screenshot:** |
41 | | - |
| 30 | +▶️ **Screenshot:** |
| 31 | + |
42 | 32 |
|
43 | 33 | --- |
44 | 34 |
|
45 | | -### **Task 1.2 – Product Class** |
46 | | -Defines a `Product` class and a main driver that: |
47 | | -- Accepts details of **5 products** |
48 | | -- Finds the product with the **highest price** |
49 | | -- Computes **total amount spent** (price × quantity) |
| 35 | +### **Task 1.2 — Product Class** |
| 36 | +- Represents products with `pid`, `price`, and `quantity`. |
| 37 | +- `ProductMain`: |
| 38 | + - Accepts **5 products**. |
| 39 | + - Finds **highest price product**. |
| 40 | + - Calculates **total expenditure**. |
50 | 41 |
|
51 | | -📸 **Screenshots:** |
52 | | - |
53 | | - |
| 42 | +▶️ **Screenshots:** |
| 43 | + |
| 44 | + |
54 | 45 |
|
55 | 46 | --- |
56 | 47 |
|
57 | | -### **Task 1.3 – Account Class** |
58 | | -Implements: |
59 | | -- Default & parameterized constructors |
60 | | -- Deposit and withdraw methods |
61 | | -- Balance display |
| 48 | +### **Task 1.3 — Account Class** |
| 49 | +- Implements `deposit`, `withdraw`, and `display` methods. |
| 50 | +- Includes default + parameterized constructors. |
62 | 51 |
|
63 | | -📸 **Screenshot:** |
64 | | - |
| 52 | +▶️ **Screenshot:** |
| 53 | + |
65 | 54 |
|
66 | 55 | --- |
67 | 56 |
|
68 | | -### **Task 1.4 – Inheritance (Person → Employee)** |
69 | | -Contains `XYZ.java`: |
70 | | -- Base class: `Person` |
71 | | -- Subclass: `Employee` |
72 | | -- Demonstrates constructor chaining using `super` |
| 57 | +### **Task 1.4 — Inheritance (Person → Employee)** |
| 58 | +- `Employee` extends `Person`. |
| 59 | +- Adds `employeeID` and `salary`. |
| 60 | +- Uses `super()` for parent initialization. |
73 | 61 |
|
74 | | -📸 **Screenshot:** |
75 | | - |
| 62 | +▶️ **Screenshot:** |
| 63 | + |
76 | 64 |
|
77 | 65 | --- |
78 | 66 |
|
79 | | -## ▶️ How to Run |
| 67 | +## ▶️ Running the Programs |
80 | 68 |
|
| 69 | +### **1. Clone the Repository** |
81 | 70 | ```bash |
82 | | -javac *.java |
| 71 | +git clone https://github.com/TheComputationalCore/java-oop-fundamentals.git |
| 72 | +cd java-oop-fundamentals/src |
83 | 73 | ``` |
84 | 74 |
|
85 | | -Run a specific task: |
| 75 | +### **2. Compile** |
| 76 | +```bash |
| 77 | +javac *.java |
| 78 | +``` |
86 | 79 |
|
87 | | -| Task | Command | |
88 | | -|------|---------| |
89 | | -| 1.1 | `java Person` | |
90 | | -| 1.2 | `java Product` | |
91 | | -| 1.3 | `java Account` | |
92 | | -| 1.4 | `java XYZ` | |
| 80 | +### **3. Run (examples)** |
| 81 | +```bash |
| 82 | +java Person |
| 83 | +java Product |
| 84 | +java Account |
| 85 | +java XYZ |
| 86 | +``` |
93 | 87 |
|
94 | 88 | --- |
95 | 89 |
|
96 | | -## 🧩 Requirements |
| 90 | +## 📦 Requirements |
97 | 91 | - Java JDK **8 or higher** |
98 | | -- Any IDE or terminal |
| 92 | +- Any terminal or Java IDE |
99 | 93 |
|
100 | 94 | --- |
101 | 95 |
|
| 96 | +## 📄 License |
| 97 | +This project is licensed under the MIT License. |
0 commit comments