Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

README.md

Assignment 15: Classes and Objects

  1. Class Definition:

    • Define a class named Car with attributes such as make, model, and year.
    • Write a method within the class to display information about the car.
  2. Object Creation:

    • Create an object of the Car class.
    • Set values for the attributes and call the method to display the car information.
  3. Constructor Implementation:

    • Modify the Car class to include a constructor that initializes the attributes.
    • Create multiple objects using the constructor.

Assignment 16: Inheritance

  1. Inheritance Setup:

    • Create a parent class named Vehicle with attributes common to various vehicles.
    • Create a child class named Car that inherits from Vehicle and adds specific attributes for cars.
  2. Method Overriding:

    • Define a method in the Vehicle class and override it in the Car class.
    • Demonstrate method overriding by creating objects of both classes and calling the methods.

Assignment 17: Abstract Classes

  1. Abstract Class Setup:

    • Create an abstract class named Shape with an abstract method calculate_area.
    • Create two subclasses (Circle and Rectangle) that inherit from Shape and implement the calculate_area method.
  2. Shape Calculation:

    • Create objects of both Circle and Rectangle classes.
    • Call the calculate_area method for each object and print the results.

Assignment 18: Encapsulation

  1. Encapsulation Implementation:

    • Create a class named Employee with private attributes such as name, salary, and designation.
    • Write getter and setter methods to access and modify these attributes.
  2. Data Validation:

    • Implement data validation in the setter methods to ensure that the salary is positive and the designation is a valid job title.
    • Demonstrate these validations by creating objects and attempting to set invalid values.

Instructions:

  • Encourage students to use meaningful variable names and provide comments explaining their code.
  • Remind students to handle class initialization and method calls appropriately.
  • Emphasize the importance of proper indentation in Python.
  • Encourage experimentation with different scenarios to ensure the correctness of the code.
  • Provide feedback on the usage of classes, objects, constructors, inheritance, abstract classes, and encapsulation in their solutions.