Oefeningen in oo programming

by chatgpt.

  1. Creating a Car Class: Define a Car class with properties such as x, y (for position), speed, and methods like move() to update the position based on speed, and display() to show the car on the canvas. Create multiple instances of the Car class and animate them moving across the screen.
  2. Building a Zoo Management System: Design a Animal class representing animals in a zoo with properties like name, species, and sound. Implement methods like makeSound() to display the sound the animal makes. Create subclasses like Mammal, Bird, and Reptile, each with their own specialized properties and methods. Populate the zoo with instances of these classes and simulate interactions between different types of animals.
  3. Creating a Weather Simulator: Develop a Weather class representing different weather conditions such as sunny, rainy, cloudy, etc. Each weather condition should have properties like temperature, humidity, and methods like change() to simulate changes in weather. Create instances of the Weather class and animate transitions between different weather conditions on the canvas. Additionally, implement subclasses like Rain and Snow to simulate specific types of weather phenomena.
  4. Designing a Quiz Application: Create a Question class representing quiz questions with properties like questionText, options, and correctAnswer. Implement methods like display() to show the question and options, and checkAnswer() to verify if the selected option matches the correct answer. Build a quiz application using multiple instances of the Question class.
  5. Modeling a Bank Account System: Define a BankAccount class with properties like accountNumber, balance, and methods like deposit() and withdraw() to modify the balance. Implement subclasses like SavingsAccount and CheckingAccount with specialized features such as interest calculation or overdraft protection. Create instances of these classes to simulate a bank account system.

Eloquent Architect 161

Eloquent Architect 161