Skip to content

Explore Java OOP principles with practical exercises by Stefano Caramagno. Learn encapsulation, inheritance, polymorphism, and more! πŸŒŸπŸ‘¨πŸ’»

Notifications You must be signed in to change notification settings

eternaltorment/Java_OOP_Principles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Java OOP Principles: Mastering Object-Oriented Programming Concepts

Java OOP Principles

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.

Table of Contents

Overview

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.

Topics Covered

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.

Getting Started

To get started with the Java OOP Principles repository, follow these steps:

  1. 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
  2. Navigate to the Directory: Change to the repository directory.

    cd Java_OOP_Principles
  3. Download Releases: You can find the latest releases here. Download the files you need to execute.

Usage

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.

Running the Exercises

To run an exercise, follow these steps:

  1. Open your terminal or command prompt.

  2. Navigate to the exercise directory.

  3. Compile the Java file using:

    javac ExerciseName.java
  4. Run the compiled Java program:

    java ExerciseName

Example

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.

Exercises

Exercise 1: Hello World

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!");
    }
}

Exercise 2: Basic Class Structure

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);
    }
}

Exercise 3: Inheritance

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");
    }
}

Contributing

Contributions are welcome! If you would like to contribute to this repository, please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or fix.
  3. Make your changes.
  4. Commit your changes with a clear message.
  5. Push your branch to your forked repository.
  6. Create a pull request.

Your contributions help improve this repository and assist others in learning Java OOP principles.

License

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.

Contact

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.

Java OOP