|
1 | | -# 📘 Java Basics: Control Flow |
| 1 | +# Java OOP Fundamentals |
2 | 2 |
|
3 | | - |
| 3 | + |
4 | 4 |
|
5 | | - |
6 | | -This repository contains a collection of beginner-friendly Java programs focused on **control flow**, including looping, conditional statements, number operations, and pattern generation. Each file is a standalone logic exercise designed to build foundational programming skills. |
7 | | - |
8 | | -## 📌 Overview |
9 | | - |
10 | | -This project includes simple yet foundational Java programs that cover: |
11 | | - |
12 | | -- Printing numeric ranges |
13 | | -- Checking number signs |
14 | | -- Reversing integers |
15 | | -- Comparing numbers |
16 | | -- Applying conditional logic (discount calculation) |
17 | | -- Generating patterns with nested loops |
18 | | - |
19 | | -All source files are located inside: |
20 | | - |
21 | | -``` |
22 | | -/task1 |
23 | | -``` |
| 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. |
24 | 6 |
|
25 | 7 | ## 📁 Project Structure |
26 | | - |
27 | 8 | ``` |
28 | | -java-basics-control-flow/ |
29 | | -├── task1/ |
30 | | -│ ├── CheckNumberSign.java |
31 | | -│ ├── DiscountCalculator.java |
32 | | -│ ├── FindSmallestOfThree.java |
33 | | -│ ├── NumberPatternGenerator.java |
34 | | -│ ├── NumberPatternGeneratorAlt.java |
35 | | -│ ├── PrintNumRange.java |
36 | | -│ ├── ReverseNumber.java |
37 | | -│────── Problems.md |
38 | | -├── screenshots/ |
39 | | -│ ├── discountcal.png |
40 | | -│ ├── numcheck.png |
41 | | -│ ├── pattern.png |
42 | | -│ ├── printnumrange.png |
43 | | -│ ├── reversenum.png |
44 | | -│ └── smallnum.png |
45 | | -└── README.md |
| 9 | +src/ |
| 10 | +├── Account.java |
| 11 | +├── Person.java |
| 12 | +├── Person_2.java |
| 13 | +├── Product.java |
| 14 | +├── XYZ.java |
| 15 | +└── screenshots/ |
| 16 | + ├── 1.1.png |
| 17 | + ├── 1.2.a.png |
| 18 | + ├── 1.2.b.png |
| 19 | + ├── 1.3.png |
| 20 | + └── 1.4.png |
46 | 21 | ``` |
47 | 22 |
|
48 | | -## 🖼️ Program Output Screenshots |
| 23 | +## 📝 Task Overviews |
49 | 24 |
|
50 | | -### 1️⃣ Print Number Range |
51 | | - |
| 25 | +### **Task 1.1 — Person Class** |
| 26 | +- Implements a `Person` class with `name` and `age`. |
| 27 | +- Default age is **18**. |
| 28 | +- Includes constructor + method to display info. |
52 | 29 |
|
53 | | -### 2️⃣ Check Number Sign |
54 | | - |
| 30 | +▶️ **Screenshot:** |
| 31 | + |
55 | 32 |
|
56 | | -### 3️⃣ Reverse Number |
57 | | - |
| 33 | +--- |
58 | 34 |
|
59 | | -### 4️⃣ Find Smallest of Three |
60 | | - |
| 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**. |
61 | 41 |
|
62 | | -### 5️⃣ Discount Calculator |
63 | | - |
| 42 | +▶️ **Screenshots:** |
| 43 | + |
| 44 | + |
64 | 45 |
|
65 | | -### 6️⃣ Number Pattern |
66 | | - |
| 46 | +--- |
67 | 47 |
|
68 | | -## ▶️ Running the Programs |
| 48 | +### **Task 1.3 — Account Class** |
| 49 | +- Implements `deposit`, `withdraw`, and `display` methods. |
| 50 | +- Includes default + parameterized constructors. |
69 | 51 |
|
70 | | -1. Navigate to the directory: |
| 52 | +▶️ **Screenshot:** |
| 53 | + |
71 | 54 |
|
72 | | -``` |
73 | | -cd task1 |
74 | | -``` |
| 55 | +--- |
75 | 56 |
|
76 | | -2. Compile the program: |
| 57 | +### **Task 1.4 — Inheritance (Person → Employee)** |
| 58 | +- `Employee` extends `Person`. |
| 59 | +- Adds `employeeID` and `salary`. |
| 60 | +- Uses `super()` for parent initialization. |
77 | 61 |
|
78 | | -``` |
79 | | -javac FileName.java |
80 | | -``` |
| 62 | +▶️ **Screenshot:** |
| 63 | + |
81 | 64 |
|
82 | | -3. Run the program: |
| 65 | +--- |
83 | 66 |
|
84 | | -``` |
85 | | -java FileName |
86 | | -``` |
| 67 | +## ▶️ Running the Programs |
87 | 68 |
|
88 | | -Example: |
| 69 | +### **1. Clone the Repository** |
| 70 | +```bash |
| 71 | +git clone https://github.com/TheComputationalCore/java-oop-fundamentals.git |
| 72 | +cd java-oop-fundamentals/src |
| 73 | +``` |
89 | 74 |
|
| 75 | +### **2. Compile** |
| 76 | +```bash |
| 77 | +javac *.java |
90 | 78 | ``` |
91 | | -javac PrintNumRange.java |
92 | | -java PrintNumRange |
| 79 | + |
| 80 | +### **3. Run (examples)** |
| 81 | +```bash |
| 82 | +java Person |
| 83 | +java Product |
| 84 | +java Account |
| 85 | +java XYZ |
93 | 86 | ``` |
94 | 87 |
|
95 | | -## 🧰 Requirements |
| 88 | +--- |
96 | 89 |
|
97 | | -- JDK 8 or above |
98 | | -- Any IDE or terminal capable of running Java |
| 90 | +## 📦 Requirements |
| 91 | +- Java JDK **8 or higher** |
| 92 | +- Any terminal or Java IDE |
99 | 93 |
|
100 | | -## 🙋 Contact |
| 94 | +--- |
101 | 95 |
|
102 | | -**Dinesh Chandra — TheComputationalCore** |
103 | | -GitHub: https://github.com/TheComputationalCore |
104 | | -YouTube: https://www.youtube.com/@TheComputationalCore |
| 96 | +## 📄 License |
| 97 | +This project is licensed under the MIT License. |
0 commit comments