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...


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<br>Testing String Method<br>Ted Arroway<br>User: xyz365<br>Employee ID: 547813657<br>Role:<br>admin<br>Password:<br>WwwZy&w899<br>User: 2s5r85<br>Palmer Joss<br>Employee ID: 141157891<br>Role:<br>base<br>Password:<br>T4388Numinou$Ness<br>User: mj9674<br>David Drumlin<br>Employee ID: 226714239<br>Role:<br>base<br>Password:<br>NO PASSWORD SET<br>User: whosit<br>Ian Broderick<br>Employee ID: 951753286<br>Role:<br>admin<br>Password:<br>Quisl1nG&H3r3<br>User: 554790<br>Michael Kitz<br>Employee ID: 735914862<br>Role:<br>base<br>Password:<br>NO PASSWORD SET<br>

Extracted 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<br>В<br>C<br>D<br>E<br>F<br>G<br>xyz365 Ted Arroway<br>5.48E+08 admin<br>WwwZy&w899<br>T4388Numinou$Ness<br>2s5r85 Palmer Joss<br>1.41E+08 base<br>mj9674 David Drumlin 2.27E+08 base<br>whosit lan Broderick 9.52E+08 admin<br>Quisl1nG&H3r3<br>554790 Michael Kitz<br>7.36E+08 base<br>

Extracted 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

Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here