|
1 | | -# Java OOP Task 3 |
2 | | - |
3 | | -This repository contains Java programs demonstrating Object-Oriented Programming (OOP) concepts, including encapsulation, abstraction, interfaces, and class relationships. The project includes two main tasks: a Library Management System and a Taxable interface implementation for calculating taxes on employees and products. |
4 | | - |
5 | | -## Project Structure |
6 | | - |
7 | | -- **Book.java**: Defines the `Book` class with attributes `bookID`, `title`, `author`, and `isAvailable` (Task 1). |
8 | | -- **Library.java**: Implements the `Library` class to manage an array of `Book` objects with methods to add, remove, search, and display books (Task 1). |
9 | | -- **Taxable.java**: Defines the `Taxable` interface with constants `salesTax` and `incomeTax`, and an abstract method `calcTax()` (Task 2). |
10 | | -- **Employee.java**: Implements the `Employee` class with the `Taxable` interface to calculate income tax on yearly salary (Task 2). |
11 | | -- **Product.java**: Implements the `Product` class with the `Taxable` interface to calculate sales tax on unit price (Task 2). |
12 | | -- **Main.java**: Contains the main method (likely `DriverMain`) to accept user input for employee and product information and display respective taxes (Task 2). |
13 | | -- **1.a.png, 1.b.png, 1.c.png, 1.d.png, 2.png**: Screenshots of the code implementations for each task. |
14 | | - |
15 | | -## Tasks Overview |
16 | | - |
17 | | -### Task 1: Library Management System |
18 | | -This task models a library system using OOP principles: |
19 | | -- **Book Class**: Represents a book with attributes `bookID`, `title`, `author`, and `isAvailable`. |
20 | | -- **Library Class**: Manages a collection of books using an array. Provides methods to: |
21 | | - - Add a book to the library. |
22 | | - - Remove a book from the library. |
23 | | - - Search for a book by `bookID`. |
24 | | - - Display all books in the library. |
25 | | -- The system allows user interaction to perform these operations. |
26 | | - |
27 | | -### Task 2: Taxable Interface Implementation |
28 | | -This task demonstrates the use of interfaces and abstraction for tax calculations: |
29 | | -- **Taxable Interface**: Defines constants `salesTax = 7%` and `incomeTax = 10.5%`, and an abstract method `calcTax()`. |
30 | | -- **Employee Class**: Implements `Taxable` to calculate income tax on the yearly salary. Attributes include `empId`, `name`, and `salary`. |
31 | | -- **Product Class**: Implements `Taxable` to calculate sales tax on the unit price of a product. Attributes include `pid`, `price`, and `quantity`. |
32 | | -- **DriverMain (Main Class)**: Accepts user input for one employee and one product, then calculates and displays the income tax for the employee and sales tax for the product. |
33 | | - |
34 | | -## How to Run |
35 | | - |
36 | | -1. **Clone the Repository**: |
37 | | - ```bash |
38 | | - git clone https://github.com/thesoulseizure/task-3.git |
39 | | - ``` |
40 | | -2. **Navigate to the Project Directory**: |
41 | | - ```bash |
42 | | - cd task-3 |
43 | | - ``` |
44 | | -3. **Compile the Java Files**: |
45 | | - ```bash |
46 | | - javac *.java |
47 | | - ``` |
48 | | -4. **Run the Program**: |
49 | | - - For Task 1 (Library Management System): The interaction logic is likely in `Library.java` or a separate main method within it. Check the code and run: |
50 | | - ```bash |
51 | | - java Library |
52 | | - ``` |
53 | | - - For Task 2 (Taxable Interface): Run the main class: |
54 | | - ```bash |
55 | | - java Main |
56 | | - ``` |
| 1 | +# Java OOP Interfaces & Abstraction |
57 | 2 |
|
58 | | -## Requirements |
| 3 | +This repository contains Java programs demonstrating essential Object-Oriented Programming (OOP) concepts such as **encapsulation, abstraction, interfaces, and class relationships**. The project is organized into **two major tasks**: |
| 4 | + |
| 5 | +1. **Library Management System** |
| 6 | +2. **Taxable Interface Implementation** |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | +## 📁 Project Structure |
| 11 | + |
| 12 | +``` |
| 13 | +. |
| 14 | +├── Book.java |
| 15 | +├── Library.java |
| 16 | +├── Taxable.java |
| 17 | +├── Employee.java |
| 18 | +├── Product.java |
| 19 | +├── Main.java |
| 20 | +├── 1.a.png |
| 21 | +├── 1.b.png |
| 22 | +├── 1.c.png |
| 23 | +├── 1.d.png |
| 24 | +└── 2.png |
| 25 | +``` |
| 26 | + |
| 27 | +### File Overview |
| 28 | +- **Book.java** – Defines the `Book` class with attributes `bookID`, `title`, `author`, and `isAvailable`. |
| 29 | +- **Library.java** – Manages an array of `Book` objects; methods to add, remove, search, and display. |
| 30 | +- **Taxable.java** – Interface defining constants `salesTax`, `incomeTax`, and abstract method `calcTax()`. |
| 31 | +- **Employee.java** – Implements `Taxable` to compute income tax. |
| 32 | +- **Product.java** – Implements `Taxable` to compute sales tax. |
| 33 | +- **Main.java** – Driver for tax calculations. |
| 34 | + |
| 35 | +--- |
| 36 | + |
| 37 | +## 📚 Task 1 — Library Management System |
| 38 | + |
| 39 | +### Book Class |
| 40 | +Represents: |
| 41 | +- `bookID` |
| 42 | +- `title` |
| 43 | +- `author` |
| 44 | +- `isAvailable` |
| 45 | + |
| 46 | +### Library Class |
| 47 | +Features: |
| 48 | +✔ Add books |
| 49 | +✔ Remove books |
| 50 | +✔ Search by `bookID` |
| 51 | +✔ Display all books |
| 52 | + |
| 53 | +### 📸 Screenshots |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | +--- |
| 60 | + |
| 61 | +## 🧮 Task 2 — Taxable Interface Implementation |
59 | 62 |
|
60 | | -- Java Development Kit (JDK) 8 or higher. |
61 | | -- A terminal or IDE to compile and run Java programs. |
| 63 | +### Taxable Interface |
| 64 | +Defines: |
| 65 | +- `salesTax = 0.07` |
| 66 | +- `incomeTax = 0.105` |
| 67 | +- `calcTax()` abstract |
| 68 | + |
| 69 | +### Employee Class |
| 70 | +Computes **income tax** on salary. |
| 71 | + |
| 72 | +### Product Class |
| 73 | +Computes **sales tax** on product price. |
| 74 | + |
| 75 | +### 📸 Screenshot |
| 76 | + |
| 77 | + |
| 78 | +--- |
| 79 | + |
| 80 | +## ▶️ Running the Programs |
| 81 | + |
| 82 | +### Clone |
| 83 | +```bash |
| 84 | +git clone https://github.com/TheComputationalCore/java-oop-interfaces-abstraction.git |
| 85 | +``` |
| 86 | + |
| 87 | +### Compile |
| 88 | +```bash |
| 89 | +javac *.java |
| 90 | +``` |
| 91 | + |
| 92 | +### Run Task 1 |
| 93 | +```bash |
| 94 | +java Library |
| 95 | +``` |
| 96 | + |
| 97 | +### Run Task 2 |
| 98 | +```bash |
| 99 | +java Main |
| 100 | +``` |
| 101 | + |
| 102 | +--- |
| 103 | + |
| 104 | +## Requirements |
| 105 | +- Java JDK 8+ |
| 106 | +- Terminal or IDE |
62 | 107 |
|
63 | | -## Screenshots |
| 108 | +--- |
64 | 109 |
|
65 | | -The repository includes screenshots (1.a.png to 1.d.png for Task 1, and 2.png for Task 2) that show the code implementations for each task. Refer to these images to view the solutions visually. |
| 110 | +## 📝 License |
| 111 | +Add a license if needed. |
0 commit comments