Welcome to the Java OOP Principles repository! This collection showcases exercises completed during my Object-Oriented Programming course at the University of Catania. The repository is designed to help you understand and apply key OOP concepts through practical examples.
This repository contains a series of exercises that demonstrate the principles of Object-Oriented Programming (OOP) using Java. Each exercise focuses on different aspects of OOP, such as classes, objects, inheritance, encapsulation, and polymorphism.
The goal is to provide clear examples that help you grasp these concepts effectively. The exercises also incorporate essential programming skills, such as debugging and project management.
The repository includes exercises on the following topics:
- Algorithms
- Data Structures
- Debugging
- English Language
- Git
- GitHub
- Markdown
- Object-Oriented Programming
- Project Management
These topics are vital for any aspiring software developer. They provide a solid foundation for understanding how to write efficient and maintainable code.
To get started with the Java OOP Principles repository, follow these steps:
-
Clone the Repository: Use the command below to clone the repository to your local machine.
git clone https://github.com/eternaltorment/Java_OOP_Principles.git
-
Navigate to the Directory: Change to the repository directory.
cd Java_OOP_Principles
-
Download Releases: You can find the latest releases here. Download the files you need to execute.
Once you have the repository cloned and the necessary files downloaded, you can start using the exercises. Each exercise is contained within its own directory, making it easy to navigate and understand.
To run an exercise, follow these steps:
-
Open your terminal or command prompt.
-
Navigate to the exercise directory.
-
Compile the Java file using:
javac ExerciseName.java
-
Run the compiled Java program:
java ExerciseName
Hereβs a simple example of how to run an exercise:
cd Exercise1
javac HelloWorld.java
java HelloWorld
This will compile and run the HelloWorld program.
This is a classic exercise to get started with Java. It demonstrates how to create a simple Java application that prints "Hello, World!" to the console.
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
In this exercise, you will learn how to define a basic class in Java. The class Car
will have attributes like make
, model
, and year
.
public class Car {
String make;
String model;
int year;
public Car(String make, String model, int year) {
this.make = make;
this.model = model;
this.year = year;
}
public void displayInfo() {
System.out.println("Car Make: " + make);
System.out.println("Car Model: " + model);
System.out.println("Car Year: " + year);
}
}
This exercise demonstrates inheritance by creating a subclass ElectricCar
that extends the Car
class.
public class ElectricCar extends Car {
int batteryLife;
public ElectricCar(String make, String model, int year, int batteryLife) {
super(make, model, year);
this.batteryLife = batteryLife;
}
public void displayBatteryLife() {
System.out.println("Battery Life: " + batteryLife + " hours");
}
}
Contributions are welcome! If you would like to contribute to this repository, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or fix.
- Make your changes.
- Commit your changes with a clear message.
- Push your branch to your forked repository.
- Create a pull request.
Your contributions help improve this repository and assist others in learning Java OOP principles.
This repository is licensed under the MIT License. You are free to use, modify, and distribute the code, provided that you include the original license in any copies of the software or substantial portions of it.
For any questions or feedback, feel free to reach out to me via GitHub or email. I appreciate your interest in the Java OOP Principles repository!
You can also check the latest releases here for updates and new exercises.