
can you please solve #2, 3 and 4 ?
please
by using Python 3
Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. If not, PLEASE let me know before you rate, I’ll help you fix whatever issues. Thanks
Note: Please maintain proper code spacing (indentation), just copy the code part and paste it in your compiler/IDE directly, no modifications required.
#code
import random
# Person class
class Person:
# constructor taking values for name, phone and email
def __init__(self, name, phone, email):
self.__name = name
self.__phone = phone
self.__email = email
# getters and setters
def getName(self):
return self.__name
def getPhone(self):
return self.__phone
def getEmail(self):
return self.__email
def setName(self, name):
self.__name = name
def setPhone(self, phone):
self.__phone = phone
def setEmail(self, email):
self.__email = email
# Customer class inheriting from Person
class Customer(Person):
# constuctor taking values to initialize super class constructor along with value for rewards
def __init__(self, name, phone, email, rewards=0):
# passing name, phone and email to super class (Person)
super(Customer, self).__init__(name, phone, email)
self.__customer_rewards = rewards
# getter and setter for rewards
def getCustomerRewards(self):
return self.__customer_rewards
def setCustomerRewards(self, rewards):
self.__customer_rewards = rewards
# Employee class inheriting from Customer
class Employee(Customer):
# constuctor taking values to initialize super class constructor along with value for id
def __init__(self, name, phone, email, rewards=0, id=0):
# passing name, phone, email and rewards to super class (Customer)
super(Employee, self).__init__(name, phone, email, rewards)
self.__customer_id = id
def getCustomerID(self):
return self.__customer_id
def setCustomerID(self, id):
self.__customer_id = id
#recursive method to find the customer with highest rewards (question 4)
def find_customer_with_highest_rewards(cust_list):
#if cust_list is empty, returning None
if len(cust_list) == 0:
return None
#if cust_list only has one element, returning it
if len(cust_list) == 1:
return cust_list[0]
#otherwise finding rewards of customer at index 0
rewards = cust_list[0].getCustomerRewards()
#finding the customer with highest rewards in the remaining elements (cust_list[1:] will
# return a sublist of cust_list after ignoring first element)
custRemaining = find_customer_with_highest_rewards(cust_list[1:])
#if rewards of current first customer is bigger than rewards of custRemaining
if rewards > custRemaining.getCustomerRewards():
#returning first customer
return cust_list[0]
else:
#otherwise returning custRemaining
return custRemaining
#main method for testing Person, Customer and Employee classes (question 3)
def main():
#creating two lists to choose random names from
fnames = ['Alice', 'Bob', 'Cait', 'David', 'Eric', 'Ford', 'Geralt', 'Heidi', 'Isra']
lnames = ['Cooper', 'Diggle', 'Gray', 'Foreman', 'House', 'Falconer']
#creating an empty list
cust_list = []
#looping for 100 times
for i in range(100):
#choosing a random first and last name
fname = random.choice(fnames)
lname = random.choice(lnames)
#a random 10 digit phone number
phone = str(random.randint(1000000000, 9999999999))
#combining first and last names to create an email id
email = fname + '.' + lname + '@something'
#random rewards value betwen 0 and 1000
rewards = random.randint(0, 1000)
#creating an Employee with name=fname+' '+lname
cust = Employee(fname + ' ' + lname, phone, email, rewards, i)
#appending to cust_list
cust_list.append(cust)
#you may loop through customer list and print each customer's details using
#getter methods if you like.
#finding customer with highest rewards
c = find_customer_with_highest_rewards(cust_list)
#displaying details of customer with highest rewards
print('Customer with highest rewards:')
print('Name: {}, Phone: {}, Email: {}, Rewards: {}, ID: {}'.format(c.getName(), c.getPhone(),
c.getEmail(), c.getCustomerRewards(),c.getCustomerID()))
#calling main()
main()
#output
Customer with highest rewards:
Name: Geralt Diggle, Phone: 9395336894, Email:
Geralt.Diggle@something, Rewards: 998, ID: 13
#another output
Customer with highest rewards:
Name: Ford Falconer, Phone: 8653976939, Email:
Ford.Falconer@something, Rewards: 1000, ID: 95
can you please solve #2, 3 and 4 ? please by using Python 3 8:34 PM...
PLEASE YOU PYTHON 3 TO SOLVE! THANKS!
PLEASE YOU PYTHON 3 TO SOLVE! THANKS!
Example 1 Design a class named Information that holds the following personal data: .name, age, address (this attribute has a default value of “unknown"), and phone number. . All the attributes are defined as private. • Write appropriate accessor and mutator methods. • Complete the definition of the str_ method, such that it displays each Information object's data in the following format: name: "Sarah Jones” –...
Python 3 IDE/AWS Problem You are tasked with writing a new program for your company that keeps track of the customer’s information and his or her current bill. The company wants the name, address, phone number, and balance to be stored for each customer. This program will demonstrate the following: How to use a class to organize data How to use methods to access the data of a class How to create objects from a class Solving the Problem Step...
Please explain each line of code, all code will be in Java. Thank you JKL Restaurant maintains a members’ club for its customers. There are three levels of membership: (1) Basic, (2) Silver, and (3) Gold. A certain member has to be exactly a Basic, Silver, or Gold member at any point in time. Whenever a member spends money at JKL, he/she gets points and as these points are accumulated, one can redeem one or more $20 dining certificates. Each Gold member can...
Solve it for java
Question Remember: You will need to read this assignment many times to understand all the details of the you need to write. program Goal: The purp0se of this assignment is to write a Java program that models an elevator, where the elevator itself is a stack of people on the elevator and people wait in queues on each floor to get on the elevator. Scenario: A hospital in a block of old buildings has a nearly-antique...
Overview This lab provides you the opportunity to insert and update data with the use of SQL commands. The lab will utilize the FLIX2YOU problem, the current schema. In order to start this lab, you must have successfully completed Lab # 6. In Lab # 6, you executed a script that was provided to you. This script created 7 of the FLIX2YOU tables as documented in the Entity Relationship Diagram in the FLIX2YOU problem document. The second part of lab...
And there was a buy-sell arrangement which laid out the
conditions under which either shareholder could buy out the other.
Paul knew that this offer would strengthen his financial
picture…but did he really want a partner?It was going to be a long
night.
read the case study above and answer this question
what would you do if you were Paul with regards to financing,
and why?
ntroductloh Paul McTaggart sat at his desk. Behind him, the computer screen flickered with...