Most programming is not done in one small sprint. Instead most programs are written over large periods of time, in large teams. As the software team builds their software, they often discover new features they would like to support, and old features that were poorly designed. Likewise, as software testing continues, the users of a system (or the people paying you to build it) may make changes to how they want features to work.
While common, this sort of software evolution is remarkably hard to simulate in a teaching environment. This homework, however, seeks to emulate it. In this homework we will be taking "Feedback" from the USMASY clients about the testing version we delivered in HW8. Based on their feedback we will be adding two new commands and substantially altering one of the commands we've already designed.
USMASY system feedback
The USer MAnagement SYstem that we delivered in HW8 was generally well received. While our clients would have preferred to see the full feature set in the first development test, they understand that it wouldn't be possible under the deadline. After seeing how the current version of USMASY worked, they have one new feature they would like to add, one feature from their original USMASY specification they would like to have you prioritize and deliver before the next version, and one core feature they would like changed.
Changes to the load operation The USMASY clients have requested the following changes to the load behavior:
High Priority Task - Save In the "Original" USMASY outline there was a save operation, which would write an accounts file for future use. We cut this for time, but the clients would like to see this in the next testing version. The save operation should create a new file in the standard USMASY file format: the first line should list the count of users, Following that should be a list of all users, in order, formatted as username < space> password. The files created by the save operation should be directly loadable by the load operation. If the user loads one file and then saves, it should simply create a copy of the loaded file. However, if the user loads two or three files, the saved file should be a combination of all source files.
New Operation - stats To help with testing, the clients have added for a new operation be added to USMASY - the "stats" operation. When the user types the stats command it should print the number of users currently loaded into the USMASY system. After that, it should optionally allow printing all usernames in the order they were loaded.
While this is an extra operation, our team agreed that it should be easy enough to add and agreed to add this into the next release of USMASY. This is also a somewhat strategic decision - 3 our team was having a lot of trouble testing that load operation and think that this might help us test out work before showing it to the clients.
Your first task should be to add the stats command. This should work essentially the same way with the HW8 load and the HW9 load commands, and having it written will help out a bit with testing the updated load.
Requirements
The changes in file format and load are the primary hard-part of this change, therefore we will focus on changes outside of the command first.
Requirements
To begin, simply change the SystemUser array to a pointer and use a new command to allocate an array of the same initial size as found in the code. You will want to add a line of code to delete at this point as well. You may need to change some arrays to pointers in function parameters, but from there your code from HW8 should compile correctly again.
Before starting the third task you will need to change the inital size of the array to something small such as 1 "empty" user. The inital array will not actually be used once we change the load command, so it can be very small.
While the user interface (cin / cout) for this command is unchanged, it will need to change a lot in it's behavior. The expected behavior and changes are detailed in the introduction section of this homework, but we can provide some hints here.
Things to think about / hints:
This command asks you to create a new accounts file based on whatever data is currently loaded. The format of this file is exactly as the format used by a load command. You should be able to load several files, save them together as one "big" file, and then run the program again loading only the big file to get the same effect as loading the several smaller files. The count of users you put in the first line of the file should be correct to the accounts you print. Each following line should contain exactly one SystemUser described by it's username and password. Your overloaded << operator should do most of the work here. The file should be named whatever the user types, if the user wants a .usmasy filename, they should type that. If the user wants a .txt filename they should type that, etc.
These examples make use of the usmasy file posted online.
Example 1
In this example, our user views the new help page and stat command, but gets a bit confused with the yes/no prompt.
Welcome to USMASY the user management system
enter command: help
Welcome to USMASY the user management system
The USMASY commands are:
* help
* stats
* load
* save
* login
* exit
enter command: stats
There are 0 current users loaded
would you like to see all users? (y/n)?: w
would you like to see all users? (y/n)?: q
would you like to see all users? (y/n)?: n
enter command: exit
Goodbye!
Running this example should not create or change any files.
Example 2
In this example the user loads a small testing file, logs in, and shows off the stats command a bit
Welcome to USMASY the user management system
enter command: load
enter a USMASY file name: NotAFile
unable to open NotAFile
enter command: load
enter a USMASY file name: newUsers.usmasy
enter command: login
username: Minymu
password: fbC5DDU5Pzkf5jb2
ERROR: incorrect password
password: empty
ERROR: incorrect password
password: WRpkx7sbv2SPdYB4
login successful
enter command: stats
There are 6 current users loaded
would you like to see all users? (y/n)?: +
would you like to see all users? (y/n)?: y
0: BrainyLive
1: Minymu
2: Dreamyca
3: WannaEver
4: StarThesoy
5: Empreek
enter command: exit
Goodbye!
Running this example should not create or change any files.
Example 3
In this example the user loads two files, checking logins as they go to make sure only the right data is available. They then use stats to confirm loading and loading order, and finally save the two files in a combined file.
Welcome to USMASY the user management system
enter command: load
enter a USMASY file name: week3Accounts.usmasy
enter command: stats
There are 30 current users loaded
would you like to see all users? (y/n)?: n
enter command: login
username: angelfishpenalty
password: MTmdaK6W
login successful
enter command: login
username: BrainyLive
ERROR: unable to find user data
enter command: load
enter a USMASY file name: newUsers.usmasy
enter command: stats
There are 36 current users loaded
would you like to see all users? (y/n)?: y
0: unpackcedric
1: iphoneexternal
2: donnybrookvivace
3: husksilo
4: strikesport
5: urifraction
6: muskyurinary
7: grubblethundercat
8: eulerpreseason
9: priscillablame
10: izzycosmogony
11: empathicoverlay
12: retailmonitors
13: proposespry
14: concernedlexy
15: unyieldingelixir
16: chaosconnie
17: exceptioncerebrum
18: euphemismedmundston
19: shyingblaze
20: angelfishpenalty
21: brittledefinitely
22: glitzyunripe
23: earactive
24: juliusshowplace
25: pileshoop
26: perchanger
27: digbyiridium
28: dollsswab
29: fingernoir
30: BrainyLive
31: Minymu
32: Dreamyca
33: WannaEver
34: StarThesoy
35: Empreek
enter command: login
username: BrainyLive
password: fbC5DDU5Pzkf5jb2
login successful
enter command: login
username: chaosconnie
password: f4aWYp89
login successful
enter command: save
enter a USMASY file name: combined.txt
enter command: exit
Goodbye!
After running this example a file "combined.txt" should be made with the following contents:
36
unpackcedric NnQzE6GL
iphoneexternal BM8F6fC8
donnybrookvivace 7f6SMcDS
husksilo gJ6n9fyG
strikesport yE9CMeTQ
urifraction KcPxJNB4
muskyurinary BCx6E3KB
grubblethundercat bYe7T6WQ
eulerpreseason 5S8t3BKD
priscillablame 5Qz4sj2K
izzycosmogony uSk7dEtq
empathicoverlay 94XzJqxd
retailmonitors 5AU4yZhJ
proposespry wSpE3d9Y
concernedlexy xG6p6BEu
unyieldingelixir PMapBF5K
chaosconnie f4aWYp89
exceptioncerebrum u7Q5dU7G
euphemismedmundston DHQyJ6G6
shyingblaze uDgc6Q2G
angelfishpenalty MTmdaK6W
brittledefinitely Us6BMV4Z
glitzyunripe t5vaxyZB
earactive cVL8u7PR
juliusshowplace SwgCUbk8
pileshoop PyQWX5Uw
perchanger 8yBHGQ3C
digbyiridium ZSgWAh6N
dollsswab 2EHxt2PC
fingernoir JbCM2W49
BrainyLive fbC5DDU5Pzkf5jb2
Minymu WRpkx7sbv2SPdYB4
Dreamyca xvfQFh6Wny9vCRsm
WannaEver nMCe5qZXX4fHGVdk
StarThesoy 3A3GLq4VpMsVBVxa
Empreek VyJeNVkRZuAq93Em
Example 4
In Example 4 we load the file made in Example 3.
Welcome to USMASY the user management system
enter command: load
enter a USMASY file name: combined.txt
enter command: stats
There are 36 current users loaded
would you like to see all users? (y/n)?: y
0: unpackcedric
1: iphoneexternal
2: donnybrookvivace
3: husksilo
4: strikesport
5: urifraction
6: muskyurinary
7: grubblethundercat
8: eulerpreseason
9: priscillablame
10: izzycosmogony
11: empathicoverlay
12: retailmonitors
13: proposespry
14: concernedlexy
15: unyieldingelixir
16: chaosconnie
17: exceptioncerebrum
18: euphemismedmundston
19: shyingblaze
20: angelfishpenalty
21: brittledefinitely
22: glitzyunripe
23: earactive
24: juliusshowplace
25: pileshoop
26: perchanger
27: digbyiridium
28: dollsswab
29: fingernoir
30: BrainyLive
31: Minymu
32: Dreamyca
33: WannaEver
34: StarThesoy
35: Empreek
enter command: login
username: strikesport
password: yE9CMeTQ
login successful
enter command: login
username: Empreek
password: VyJeNVkRZuAq93Em
login successful
enter command: load
enter a USMASY file name: week2Accounts.usmasy
enter command: stats
There are 106 current users loaded
would you like to see all users? (y/n)?: n
enter command: exit
Goodbye!
After running this example no new files should be made, and no files should be changed.