Question

In: Computer Science

Design a class that holds the following data regarding a music album: artist, title, number of...

Design a class that holds the following data regarding a music album: artist, title, number of tracks, and year released. Write appropriate accessor and mutator methods. Also, write a program that creates three instances of the class. Each instance will hold information about a different music album. Make sure to display all of the information for all three albums to the screen in an organized manner.

**Using python**

Solutions

Expert Solution

Program:

class Album:
   def __init__(self,artist,title,numTracks,year):
       self.artist=artist
       self.title=title
       self.numTracks=numTracks
       self.year=year
  
   def setArtist(self,artist):
       this.artist=artist

   def setTitle(self,title):
       this.title=title

   def setNumTracks(self,numTracks):
       this.numTracks=numTracks

   def setYear(self,year):
       self.year=year
  
   def getArtist(self):
       return    self.artist
   def getTitle(self):
       return self.title
   def getNumTracks(self):
       return self.numTracks
   def getYear(self):
       return self.year


album1=Album("Enrique","Slim Shady",10,1997)
album2=Album("JLegend","GetLifted",8,2004)
album3=Album("Adele","TwentyFive(25)",12,2015)

print("\nArtist\tTitle\t\tNumber of tracks\tYear");
print("----------------------------------------------------------")
print(album1.getArtist(),end="\t")
print(album1.getTitle(),end="\t")
print(album1.getNumTracks(),end="\t\t\t")
print(album1.getYear(),end="\n")
print(album2.getArtist(),end="\t")
print(album2.getTitle(),end="\t")
print(album2.getNumTracks(),end="\t\t\t")
print(album2.getYear(),end="\n")
print(album3.getArtist(),end="\t")
print(album3.getTitle(),end="\t")
print(album3.getNumTracks(),end="\t\t\t")
print(album3.getYear(),end="\n\n")


Program Screenshot:

Output:


Related Solutions

PHP You will be using the object oriented features of PHP to design a music album...
PHP You will be using the object oriented features of PHP to design a music album processing page. First you will build a form page called addAlbum.php. This form will contain text fields for album title, artist, publisher (Sony, BMI, etc.) and genre. Add two more fields of your choice. You will post this form to the file process.php. If all the fields have values, we will create a new Album object and print the details of the object. You...
Develop a Domain Class Model with proper annotation on paper. Music An album has a name...
Develop a Domain Class Model with proper annotation on paper. Music An album has a name and a release date. An album has a collection of 1 or more songs. And a song may be on one album, but does not have to be (that is a song can exist whether it is on an album or not). A song has a title and a length in seconds. A song is created by one artist. All artists have a name....
TestLibrary.java Design and implement a class named Book. A book has a serial number, a title,...
TestLibrary.java Design and implement a class named Book. A book has a serial number, a title, an author, and a publisher. Create appropriate constructor(s) and accessor and mutator methods for the Book class. Add a static variable to the Book class and set its initial value to 100000000. When a new book is created, this static variable is automatically incremented by 1 and the new value is assigned as the serial number of the new book. Design and implement a...
Programming Exercise Implement the following class design: class Tune { private:    string title; public:   ...
Programming Exercise Implement the following class design: class Tune { private:    string title; public:    Tune();    Tune( const string &n );      const string & get_title() const; }; class Music_collection { private: int number; // the number of tunes actually in the collection int max; // the number of tunes the collection will ever be able to hold Tune *collection; // a dynamic array of Tunes: "Music_collection has-many Tunes" public: // default value of max is a conservative...
a. Design a class named ItemForSale that holds data about items placed for sale on Carlos's...
a. Design a class named ItemForSale that holds data about items placed for sale on Carlos's List, a classified advertising website. Fields include an ad number, item description, asking price, and phone number. Include get and set methods for each field. Include a static method that displays the website's motto ("Sell Stuff Locally!"). Include two overloaded constructors as follows: A default constructor that sets the ad number to 101, the asking price to $1, and the item description and phone...
Create a class that holds data about a job applicant. Include a name, a phone number,...
Create a class that holds data about a job applicant. Include a name, a phone number, and four Boolean fields that represent whether the applicant is skilled in each of the following areas: word processing, spreadsheets, databases, and graphics: Include a constructor that accepts values for each of the fields. Also include a get method for each field. Create an application that instantiates several job applicant objects and pass each in turn to a Boolean method that determines whether each...
Program Specification Design an inventory class that stores the following members: serialNum: An integer that holds...
Program Specification Design an inventory class that stores the following members: serialNum: An integer that holds a part's serial number. manufactDate: A member that holds the date the part was manufactured. lotNum: An integer that holds the part's lot number. The class should have appropriate setter and getter functions. Next, design a stack class that can hold objects of the class described above. If you wish, you may use the linked list from program 5 as a basis for designing...
Assume you have created the following data definition class: public class Book {    private String title;...
Assume you have created the following data definition class: public class Book {    private String title;    private double cost;       public String getTitle() { return this.title; }    public double getCost() { return this.cost; }       public void setTitle(String title) {       this.title = title;    } // Mutator to return true/false instead of using exception handling public boolean setCost(double cost) {       if (cost >= 0 && cost < 100) {          this.cost = cost;          return true;       }       else {          return false;       }...
Create a class named CollegeCourse that includes the following data fields: dept (String) - holds the...
Create a class named CollegeCourse that includes the following data fields: dept (String) - holds the department (for example, ENG) id (int) - the course number (for example, 101) credits (double) - the credits (for example, 3) price (double) - the fee for the course (for example, $360). All of the fields are required as arguments to the constructor, except for the fee, which is calculated at $120 per credit hour. Include a display() method that displays the course data....
Design a ship class that has the following data fields: A data field for the name...
Design a ship class that has the following data fields: A data field for the name of the ship (a string). A data field for the year that the ship was built (a String). A constructor and appropriate accessors and mutators. A toString method that displays the ship’s name and the year it was built. Design a CruiseShip class that extends the Ship class. The CruiseShip class should have the following member: A field for the maximum number of passengers...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT