Requirements: 1. Name your code user.py. 2. Produce the required code to describe the User class per the UML Class Diagram requirements provided to you. a. Define the Class appropriately. Use object as the designated superclass. b. Code the constructor for the class as discussed in the demonstration videos posted to Blackboard.  Use the correct, Python-defined name for the constructor method.  Remember that the argument/parameter “self” is always included as the first argument/parameter in the constructor header/definition line.  The attribute password will use a default value of “None”. That is, set the password attribute to null or None when no value is present for that argument/parameter. b. Code a mutator or set method for each listed attribute.  Remember that the argument/parameter “self” is always included as the first argument/parameter in the mutator header/definition line.  The only other parameter included should be a value of the appropriate type for the specific attribute.  HINT: It would be smart to make certain that the value stored for the attribute employeeId is an integer. c. Code an accessor or get method for each listed attribute.  Remember that the argument/parameter “self” is always included as the first argument/parameter in the accessor header/definition line.  No other argument/parameter should ever be included in the accessor header/definition.  NOTE: Check the value of the password attribute in the accessor method prior to returning a value. If no value has been set for password, return “NO PASSWORD SET”. d. Code a String method for the class.  Use the correct, Python-defined name for the String method.  Use the following format string to build the string returned by this method: ( "User: %‐20s%‐40s\n\tEmployee ID: %s" + “\n\tRole: %s\n\tPassword: %s/n")  The second replacement value should be the name attribute. 3. Comment your code. a. Include a description of the class at the top of your code. b. Include comment(s) describing the purpose of the mutator/set methods. (If you group all mutator methods together, you may use a single block comment.) c. Include comment(s) describing the purpose of the accessor/get methods. (If you group all accessor methods together, you may use a single block comment.) d. Include a description for the String method. 4. Under NO CIRCUMSTANCES should your code include any input or output statements of any sort or type. If print statements are used for debugging, you must remove them (or comment out) prior to submission. Failure to adhere to this rule triggers a 20 point deduction from the rubric-determined score. 5. Test your User class to insure that it performs as expected. Be sure that you have tested all of the methods required/listed in the UML. The assignment materials include a batch test harness and a test case input file.   Test Cases code: """ This is what is referred to as a "batch test harness". Essentially, that means that many test cases may be run in a single execution of the code. This method of testing is incredibly valuable when we must run many dozens (or hundreds or thousands) of test cases in order to validate code. """ from user import User # We must import the class definition #============================================================================= def main( ): """ The main function will essentially call other functions to do all the "heavy lifting". As usual, this funciton is the "traffic cop" directing the action rather than the one taking action. """ # Call a function to collect the test case and instantiate User objects testCases = getTestCases( ) # Use a for loop to check the User objects - Are they what we expect? print( "%50s" % "Testing String Method" ) for case in testCases: print( case ) # end for loop # end main Function #============================================================================= def getTestCases( ): """ This function will prompt for an input file name. (You are MORE THAN WELCOME TO CREATE YOUR OWN TEST CASES!) The file containing the test cases will be opened for reading. Each line represents a test case. The individual lines will be broken into their constituent pieces and those pieces will then be used to INSTANTIATE User objects for testing. """ caseFile = input( "Which file do you want to use for testing? " ) inputFile = open( caseFile, 'r' ) # Open the file for reading/input caseList = [ ] # Declare an empty List structure for line in inputFile: # Each line in the file = 1 test case line = line.strip( ) # Strip the newline character from input items = line.split( "," ) # Split into "parts" based on comma # Instantiate a User object for testing testCase = User( items[ 0 ], # userId items[ 1 ], # name items[ 2 ], # employeeNbr items[ 3 ], # role items[ 4 ] ) # password # Add the new User object to the List structure caseList.append( testCase ) # end for loop # Return the completed List structure to caller return caseList # end getTestCases Function #============================================================================ if __name__ == "__main__": main( )

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Requirements:
1. Name your code user.py.
2. Produce the required code to describe the User class per the UML Class Diagram
requirements provided to you.
a. Define the Class appropriately. Use object as the designated superclass.
b. Code the constructor for the class as discussed in the demonstration videos posted
to Blackboard.
 Use the correct, Python-defined name for the constructor method.
 Remember that the argument/parameter “self” is always included as the
first argument/parameter in the constructor header/definition line.
 The attribute password will use a default value of “None”. That is, set the
password attribute to null or None when no value is present for that
argument/parameter.
b. Code a mutator or set method for each listed attribute.
 Remember that the argument/parameter “self” is always included as the
first argument/parameter in the mutator header/definition line.
 The only other parameter included should be a value of the appropriate
type for the specific attribute.
 HINT: It would be smart to make certain that the value stored for the
attribute employeeId is an integer.
c. Code an accessor or get method for each listed attribute.
 Remember that the argument/parameter “self” is always included as the
first argument/parameter in the accessor header/definition line.
 No other argument/parameter should ever be included in the accessor
header/definition.
 NOTE: Check the value of the password attribute in the accessor method
prior to returning a value. If no value has been set for password, return
“NO PASSWORD SET”.
d. Code a String method for the class.
 Use the correct, Python-defined name for the String method.
 Use the following format string to build the string returned by this method:
( "User: %‐20s%‐40s\n\tEmployee ID: %s" +
“\n\tRole: %s\n\tPassword: %s/n")
 The second replacement value should be the name attribute.
3. Comment your code.
a. Include a description of the class at the top of your code.
b. Include comment(s) describing the purpose of the mutator/set methods. (If you
group all mutator methods together, you may use a single block comment.)
c. Include comment(s) describing the purpose of the accessor/get methods. (If you
group all accessor methods together, you may use a single block comment.)
d. Include a description for the String method.

4. Under NO CIRCUMSTANCES should your code include any input or output statements of
any sort or type. If print statements are used for debugging, you must remove them (or
comment out) prior to submission. Failure to adhere to this rule triggers a 20 point
deduction from the rubric-determined score.
5. Test your User class to insure that it performs as expected. Be sure that you have tested
all of the methods required/listed in the UML.

The assignment materials include a batch test harness and a test case input file.  

Test Cases code:

"""
This is what is referred to as a "batch test harness". Essentially, that
means that many test cases may be run in a single execution of the code.

This method of testing is incredibly valuable when we must run many dozens
(or hundreds or thousands) of test cases in order to validate code.

"""
from user import User # We must import the class definition

#=============================================================================
def main( ):
"""
The main function will essentially call other functions to do all the
"heavy lifting". As usual, this funciton is the "traffic cop" directing
the action rather than the one taking action.
"""
# Call a function to collect the test case and instantiate User objects
testCases = getTestCases( )

# Use a for loop to check the User objects - Are they what we expect?
print( "%50s" % "Testing String Method" )
for case in testCases:
print( case )
# end for loop

# end main Function

#=============================================================================
def getTestCases( ):
"""
This function will prompt for an input file name. (You are MORE THAN
WELCOME TO CREATE YOUR OWN TEST CASES!) The file containing the test
cases will be opened for reading. Each line represents a test case.
The individual lines will be broken into their constituent pieces and
those pieces will then be used to INSTANTIATE User objects for testing.
"""
caseFile = input( "Which file do you want to use for testing? " )
inputFile = open( caseFile, 'r' ) # Open the file for reading/input

caseList = [ ] # Declare an empty List structure

for line in inputFile: # Each line in the file = 1 test case

line = line.strip( ) # Strip the newline character from input
items = line.split( "," ) # Split into "parts" based on comma

# Instantiate a User object for testing
testCase = User( items[ 0 ], # userId
items[ 1 ], # name
items[ 2 ], # employeeNbr
items[ 3 ], # role
items[ 4 ] ) # password

# Add the new User object to the List structure
caseList.append( testCase )
# end for loop

# Return the completed List structure to caller
return caseList
# end getTestCases Function


#============================================================================
if __name__ == "__main__":
main( )

 

Expected Output Using Provided Test Harness & Test Case File
Testing String Method
Ted Arroway
User: xyz365
Employee ID: 547813657
Role:
admin
Password:
WwwZy&w899
User: 2s5r85
Palmer Joss
Employee ID: 141157891
Role:
base
Password:
T4388Numinou$Ness
User: mj9674
David Drumlin
Employee ID: 226714239
Role:
base
Password:
NO PASSWORD SET
User: whosit
Ian Broderick
Employee ID: 951753286
Role:
admin
Password:
Quisl1nG&H3r3
User: 554790
Michael Kitz
Employee ID: 735914862
Role:
base
Password:
NO PASSWORD SET
Transcribed Image Text:Expected Output Using Provided Test Harness & Test Case File Testing String Method Ted Arroway User: xyz365 Employee ID: 547813657 Role: admin Password: WwwZy&w899 User: 2s5r85 Palmer Joss Employee ID: 141157891 Role: base Password: T4388Numinou$Ness User: mj9674 David Drumlin Employee ID: 226714239 Role: base Password: NO PASSWORD SET User: whosit Ian Broderick Employee ID: 951753286 Role: admin Password: Quisl1nG&H3r3 User: 554790 Michael Kitz Employee ID: 735914862 Role: base Password: NO PASSWORD SET
A
В
C
D
E
F
G
xyz365 Ted Arroway
5.48E+08 admin
WwwZy&w899
T4388Numinou$Ness
2s5r85 Palmer Joss
1.41E+08 base
mj9674 David Drumlin 2.27E+08 base
whosit lan Broderick 9.52E+08 admin
Quisl1nG&H3r3
554790 Michael Kitz
7.36E+08 base
Transcribed Image Text:A В C D E F G xyz365 Ted Arroway 5.48E+08 admin WwwZy&w899 T4388Numinou$Ness 2s5r85 Palmer Joss 1.41E+08 base mj9674 David Drumlin 2.27E+08 base whosit lan Broderick 9.52E+08 admin Quisl1nG&H3r3 554790 Michael Kitz 7.36E+08 base
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Software Development
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education