Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A team designer supposes to create application called NoCoin which any user can create account with a unique username and store credit into the account.

A team designer supposes to create application called NoCoin which any user can create account with a unique username and store credit into the account.

The NoCoin app has all the bank capabilities including increasing the credits (no password needed), open new accounts. See the amount of the account with username and password. Moreover, an admin should be able to see all the existing accounts and the total amount of all the accounts.

A software team initiates the noCoin based software but they abanded the project halfway!

Your job is to analyze what they have done. Without any change in structure finish what they started!

Read a comment for what each module needs to be done! download the provided zip file.

SERVER.py

from db import Database import cv def main(): database = Database() while True: choice = input(cv.MENU) if choice == '1': admin = input(cv.ADMIN_PASS) database.print_all(admin) elif choice == '2': admin = input(cv.ADMIN_PASS) database.get_number_of_users(admin) elif choice == '3': admin = input(cv.ADMIN_PASS) database.get_total_amount_of_credits(admin) elif choice == '4': username = input(cv.GET_USERNAME) password = input(cv.GET_PASSWORD) database.show_credit_of_user(username, password) elif choice == '5': username = input(cv.NEW_USERNAME) password = input(cv.GET_PASSWORD) database.add_user(username, password) elif choice == '6': username = input(cv.GET_USERNAME) password = input(cv.GET_PASSWORD) money = int(input(cv.AMOUNT)) database.add_credit_to_user(money, username, password) elif choice == '7': money = int(input(cv.AMOUNT_SEND)) username1 = input(cv.GET_USERNAME) password1 = input(cv.GET_PASSWORD) username2 = input(cv.TO_USERNAME) database.send_credit_from_user_to_user(money, username1, password1, username2) elif choice == '8': break if __name__ == '__main__': main() 

CV.py

MENU = """ ===== N O COIN ===== 1. View all users 2. View count of users 3. View total credit 4. View my credit 5. Sign up new user 6. Add my credit 7. Transfer credit 8. Exit ===== C H O O S E ===== """ ADMIN_PASS = ">> Admin password: " GET_USERNAME = ">> Username: " GET_PASSWORD = ">> Password: " NEW_USERNAME = ">> New Username: " TO_USERNAME = ">> To username: " AMOUNT = ">> Credit: " AMOUNT_SEND = ">> Credit to send: " 

db.py

class User: def __init__(self, username, password, credit=0): self.username = username self.password = password self.credit = int(credit) def __str__(self): return "{} {} {}".format(self.username, self.password, self.credit) def __repr__(self): return str(self) class Database: def __init__(self): self.users = self.read() self.admin_password = "1234" def save(self): new_list = [str(user) for user in self.users] text = ' '.join(new_list) with open("accounts.ck","w+") as f: f.write(text) def read(self): with open("accounts.ck","r") as f: text = f.read() lines = text.splitlines() return list([User(*line.split()) for line in lines]) def find_user(self, username): for user in self.users: if user.username == username: return username return None def print_all(self, password): # check for admin password pass def get_number_of_users(self, password): # check for admin password pass def get_total_amount_of_credits(self, password): # 1. check for admin password # 2. define sum = 0 # 3. loop on all of self.users pass def user_exists(self, username): for user in self.users: pass def username_matches_password(self, username, password): for user in self.users: # find the user with that username # check username == password pass def show_credit_of_user(self, username, password): # 1. check user exists # 2. check username and password match # 3. find the user and show credit pass def add_user(self, username, password): # 1. check user does not exist # 2. create a new User(username, password) # 3. append the new user to self.users # 4. don't forget to save() ! pass def add_credit_to_user(self, money, username, password): # 1. check user does not exist # 2. create a new User(username, password) # 3. search for the user # 4. add money to user.credit # 5. print new credit # 6. don't forget to save() ! pass def send_credit_from_user_to_user(self, money, username1, password1, username2): # 1. check user1 exists # 2. check user2 exists # 3. check username1 and password1 match # 4. check user1 has enough credit # 5. find user1 and user2 # 6. send money from user1 to user2 # 7. show user1 credit # 8. don't forget to save() ! pass 

We are required to make changes in db.py file

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions