Question: Can you please look at my python code and tell me the problem? (and the solution) every thing seems fine but it does not run.

Can you please look at my python code and tell me the problem? (and the solution) every thing seems fine but it does not run.

The whole question is this but my code is for number 1 :

Create a python program that imitates a schoolbag containing two binders. The program should contain three classes: Binder, SchoolBag and BagTester (which consists of the main method).

  1. The Binder class.
    1. Create all the necessary instance fields for the class. Each Binder object should keep track the following information:
      • Label
      • Color
      • Number of sheets of paper in the binder
    2. Create the class constants for the class:
      • Weight of each sheet of paper
      • Weight of an empty binder
    3. Create all the necessary methods. Each Binder object should perform the following tasks:
      • Add sheets to the binder
      • Calculate the total weight of the binder (with the sheets in it)
      • Comparing the weight of the implicit and explicit binder
      • Allows the capability to print info about the binder
    4. Create a constructor that initializes the instance variables of the object being constructed.
  1. The SchoolBag class:
    1. A schoolbag has a style (String) and consists of two binders. Create the instance fields accordingly.
    2. Create the class constants for the class:
      • Weight of the empty schoolbag
    3. Create the methods that perform the following tasks:
      • Add sheet(s) to given binder (specified by id / index)
      • Remove sheet(s) from given binder
      • Calculate the average weight of a binder in the bag
      • Calculate the total weight of the schoolbag (with the binders)
      • Allows the capability to print info about the schoolbag
    • Create two constructors:
      • The first one takes two object reference parameters. The two objects will be the two binders. The object must already exist before using this constructor.
      • The second one takes as parameters all the information of the two binders. The two binders will be created in the constructor and assigned to the corresponding fields.

  1. Create a BagTester class that performs the following:
    1. Prompt user for information of two school bags and their content
    2. Create two instances of school bag. Use different constructors to create each instance
    3. Continue to prompt user for the following until -1 is entered for ID
      • ID for a schoolbag
      • ID for a binder in the schoolbag
      • Add or remove sheets
      • The number of sheets
    4. Print out the information of each schoolbag

And my code for it is :

class binder:

def __init__ (self,label,color,sheets):

self.__label = label

self.__color = color(black,blue, pink)

self.__sheets = sheets

def labels(self):

return self.__label

def colors (self):

return self.__color

def sheets (self):

return self.__sheets

num=0

ask=int(input("How many pages would you like to add?"))

if ask ==0:

return num

else:

print(num+ask)

sheets(sheets)

class constants:

input2 = float(input("How many papers does you binder have?"))

def __init__ (self, weightp, weightb):

self.__weightp = weightp

self.__weightb = weightb

def weightpapers (self):

return self.__weightp

if input2 == 0:

print ("The weight is 10 grams")

else:

weight = input2*0.045

print ("The weight is {} grams".format(weight1))

def weightbinder(self):

return self.__weightb

weight1= input2*0.045

totalweight=weight1+10

print ("The weight is {} grams".format(weight))

weightpaper()

weightbinder()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!