Programming Exercises

  1. LibraryBook Class

Write a class named LibraryBook which should have the following data attributes:

  • __title (for the title of the book)
  • __author (for the author of the book)
  • __isbn (for the ISBN number of the book)

 

The class should have an __init__ method to initialize these attributes and the following methods:

  • Methods to assign values to each attribute.
  • Methods to return the values of each attribute.

Write a program that creates an object of the LibraryBook class and prompts the user to enter the title, author, and ISBN number. Use the object’s accessor methods to retrieve and display this data.

 

  1. Course Class

Design a class named Course that holds the following data: course name, instructor name, number of students, and classroom number. Write appropriate accessor and mutator methods. Also, write a program that creates three instances of the class. One instance should hold your current course information, and the other two should hold information about other courses.

 

  1. Car Class

Write a class named Car that holds data about a car in a dealership. The class should store the following data: make, model, year, and price. Once you have written the class, write a program that creates three Car objects and stores different data in them.

 

  1. GroceryItem Class

Create a class named GroceryItem that holds data about an item in a grocery store. The class should store the following data: item name, quantity in stock, and price per unit.

 

Write a program that creates three GroceryItem objects and stores different data in them.

 

  1. Student Class

Design a class that holds the following student data: student ID, name, major, and GPA. Write appropriate accessor and mutator methods. Then, write a program that creates three instances of the class and stores information about three different students.

 

  1. Movie Class

Write a class named Movie that holds data about a movie in a rental store. The class should store the following data: title, genre, director, and year released. Once you have written the class, write a program that creates three Movie objects and stores different data in them.

 

  1. Employee Class

Create a class named Employee that stores the following data: employee ID, name, position, and salary. Write a program that creates three Employee objects and stores data about three different employees. Use accessor methods to retrieve and display the data.

 

  1. House Class

Design a class that holds the following data about a house: address, square footage, number of bedrooms, and price. Write appropriate accessor and mutator methods. Also, write a program that creates three instances of the class and stores information about three different houses.

 

  1. BookStore Class

Write a class named BookStore that holds data about books available in a bookstore. The class should store the following data: book title, author, price, and number of copies available. Write a program that creates three BookStore objects and stores different data in them.

 

  1. MusicAlbum Class

Create a class named MusicAlbum that stores the following data: album name, artist, genre, and release year. Write a program that creates three MusicAlbum objects and stores data about three different albums. Use accessor methods to retrieve and display the data.