ASSIGNMENT

You are going to enhance the prior assignment by doing the following.

  • Create a class that contains all prior functions, you must convert the functions to methods of that class (do not create static methods, see the lesson for the correct way to create a class) 
  • Test the application (You can create your own application to demonstrate the usage of the class library) 

Optional assignment 1
          1) Create a math class that contains add and subtract methods
          2) Create a sub-class using inheritance to add multiply and divide methods
          3) Create a simple program to demonstrate the usage of the inherited class.

       Optional assignment 2
          1) Create an employee class (id, name, hourly rate, hours worked, pay                             (hourly  rate * hours worked)
          2) Create a simple program to demonstrate the usage of the above class, the user will input (id, name, hourly rate, and hours worked), and the class will calculate the pay per employee. Be creative in how to display the data.

       Optional assignment 3
           1) Create a final grade class that will accept the weekly percentage grade to calculate the final grade.

           2) Create a simple program to demonstrate the usage of the above class, the user will input the weekly percentage grades and the program will                              calculate the final grade (use the "average equation" to calculate the final)

           3) create a dictionary with corresponding letter grades and use them as the output. 

Sample output

Use the same output from the last assignment.

Submission Instructions:

Make sure that you save your code in a text file in this format.

program:

W7_firstname_lastname.py

(You must create at least one object from the class library)

library:

W7_firstname_lastname_Mylib.py

The class Should NOT contain any UI functions such as input(), print(), format, or returning any messages

DO NOT use class variables to pass data between methods, each method should contain parameters and return at least one value.

Hints:

1) class library

"""

   comment block

"""

class dcalc():
      def add(self,fn ,sn):
          return fn+sn

      def sub…

      def …

       …..

2) Program

import the library as  sam  >>> use your initials <<<

create an object from the class

oSam = sam.dcalc() 

while True:

   try:

          # set limits lr and hr
          lr = input(low limit range)
          hr = input(high limit range)

          # get user lower range and user high range 
          ulr=enter user lower range between the lower limit and high limit
          uhr=enter user high range between the lower limit and high limit

          #check to see in ulr and uhr are in the ranges
          if(oSam.checknum(lr,ulr,hr) and oSam.checknum(lr,uhr,hr)

             …….

# Static class vs Dynamic class

#Static class is used once. For this course use dynamic class to be able to create more that one object from the same class.

#static class
class scalc():
    def add(fn, sn):
        return fn+sn
# using add()
print(scalc.add(5,7))

# The following line will cause an error
# creating object from class
o1=scalc()
print(o1.add(2,2))
# the following is not an object is just a copy
# of the static class
o1=scalc
print(o1.add(2,2))

# dynamic class
class dcalc():
      def add(self,fn ,sn):
          return fn+sn

# creating objects with dynamic class,
# you can create more than one object from the same class
obj1 = dcalc()
obj2 = dcalc()
print(obj1.add(2,2))
print(obj2.add(3,3))

# using class method/function in another method/function

class scalc():

    def add(self, fn, sn):

        return fn+sn

    def double_add(self, fn, sn):

        res_add=self.add(fn, sn)

        return res_add*2

# using double_add

oCalc=scalc()

print(oCalc.double_add(5,7)) # 24

Assessment Rubric

Exemplary (25-20)

Accomplished
(19-10)

Developing
(9-1))

Beginning
( 0)

Points Available

  • Assignment details in a comment block

The student effectively completed the assignment.

The student partially completed the assignment.

The student provided limited and meaningless substance to complete the assignment.

The student failed to complete the assignment.

25

  • Create a class in the module

The student effectively completed the assignment.

The student partially completed the assignment.

The student provided limited and meaningless substance to complete the assignment.

The student failed to complete the assignment.

25

  • Convert all the functions into methods in the class
  • Code comments

The student effectively completed the assignment.

The student partially completed the assignment.

The student provided limited and meaningless substance to complete the assignment.

The student failed to complete the assignment.

25

  • The print function used to correctly print the solution (application is running)

The student effectively completed the assignment.

The student partially completed the assignment.

The student provided limited and meaningless substance to complete the assignment.

The student failed to complete the assignment.

25

Total

100