Question

In: Computer Science

Write a Python class to represent a Salik account. The account has three attributes, a name,...

Write a Python class to represent a Salik account. The account has three attributes, a name, id, and the balance. The balance is a private attribute. The class has extra functions to add to the balance and reduce the balance. Both, these functions should return the current balance and if the balance is below AED 50.0 print the message “Note: Balance Below 50”.

Your class must work for the code given below.

 
#Test
myCar = SalikAccount()
myCar.setName("John")
myCar.setID("190300300333")
myCar.setBal(20.0)

yourCar = SalikAccount("Ahmed", "102003993", 78.5)

myCar.addBalance(500)
yourCar.reduceBalance(40)

Solutions

Expert Solution

****This requires some effort so please drop a like if you are satisfied with the solution****

I have satisfied all the requirements of the question and I'm providing the screenshots of code and output for your reference...

Code:

class SalikAccount():
    def __init__(self, name="", id="", balance=0):
        self.name = name
        self.id = id
        self.__balance = balance

    def setName(self, name):
        self.name = name

    def setId(self, id):
        self.id = id

    def setBal(self, bal):
        self.__balance = bal

    def getName(self):
        return self.name

    def getId(self):
        return self.id

    def getBal(self):
        return self.__balance

    def addBalance(self, amount):
        self.__balance += amount
        print("Money added Current Balance =", self.__balance)

    def reduceBalance(self, amount):
        if amount > self.__balance:
            print("Not enough balance reduce amount and try again...")
        else:
            self.__balance -= amount
            if self.__balance < 50:
                print("Money reduced current Balance =", self.__balance)
                print("Note: Balance below 50")
            else:
                print("Money reduced current Balance =", self.__balance)


myCar = SalikAccount()
myCar.setName("John")
myCar.setId("190300300333")
myCar.setBal(20.0)

yourCar = SalikAccount("Ahmed", "102003993", 78.5)
myCar.addBalance(500)
yourCar.reduceBalance(40)

Output Screenshot:

Code Screenshots:


Related Solutions

Using python class: Design a class called Account CLASS NAME:    Account ATTRIBUTES: -nextAcctID: int    #NOTE-...
Using python class: Design a class called Account CLASS NAME:    Account ATTRIBUTES: -nextAcctID: int    #NOTE- class-level attribute initialized to 1000 -acctID: int -bank: String -acctType: String (ex: checking, savings) -balance: Float METHODS: <<Constructor>>Account(id:int, bank: String, type:String, bal:float) +getAcctID(void): int                        NOTE: retrieving a CLASS-LEVEL attribute! -setAcctID(newID: int): void           NOTE: PRIVATE method +getBank(void): String +setBank(newBank: String): void +getBalance(void): float +setBalance(newBal: float): void +str(void): String NOTE: Description: prints the information for the account one item per line. For example: Account #:        ...
Write in Java the following: A.  A bank account class that has three protected attributes: account number...
Write in Java the following: A.  A bank account class that has three protected attributes: account number (string), customer name (string), and balance (float). The class also has a parameterized constructor and a method public void withDraw (float amount) which subtracts the amount provided as a parameter from the balance. B. A saving account class that is a child class of the bank account class with a private attribute: penality rate (float). This class also has a parameterized constructor and a...
Write a class called Account that contains: • Three privateinstance variables: name (String), account (String),...
Write a class called Account that contains: • Three private instance variables: name (String), account (String), account balance (double). • One constructor, which constructs all instances with the values given. • Getters and setters for all the instance variables. • Debit function that takes an amount from the user and subtract the balance (make sure the balance will not drop below zero after the operation, if this was the case, the function should return false else it should return true)...
Write a class named Person with data attributes for a person’s first name, last name, and...
Write a class named Person with data attributes for a person’s first name, last name, and telephone number. Next, write a class named Customer that is a subclass of the Person class. The Customer class should have a data attribute for a customer number and a Boolean data attribute indicating whether the customer wishes to be on a calling list. Demonstrate an instance of the Customer class in a simple program. Using python
IN JAVA!   Write a class Store which includes the attributes: store name, city. Write another class...
IN JAVA!   Write a class Store which includes the attributes: store name, city. Write another class encapsulating an Art Gallery, which inherits from Store. An Art Gallery has the following additional attributes: how many paintings are sold every year and the number of artists submitting artwork. Code the constructor, accessors, mutators, toString and equals method of the super class Store. Code the constructor, accessors and mutators for the subclass Art Gallery. In the Art Gallery class, also code a method...
Write a class Car that contains the following attributes: The name of car The direction of...
Write a class Car that contains the following attributes: The name of car The direction of car (E, W, N, S) The position of car (from imaginary zero point) The class has the following member functions: A constructor to initialize the attributes. Turn function to change the direction of car to one step right side (e.g. if the direction is to E,it should be changed to S and so on.) Overload the Turn function to change the direction to any...
1. Write a class called Rectangle that maintains two attributes to represent the length and width...
1. Write a class called Rectangle that maintains two attributes to represent the length and width of a rectangle. Provide suitable get and set methods plus two methods that return the perimeter and area of the rectangle. Include two constructors for this class. One a parameterless constructor that initializes both the length and width to 0, and the second one that takes two parameters to initialize the length and width. 2. Write a java program (a driver application) that tests...
Write a class Store which includes the attributes: store name and sales tax rate. Write another...
Write a class Store which includes the attributes: store name and sales tax rate. Write another class encapsulating a Book Store, which inherits from Store. A Book Store has the following additional attributes: how many books are sold every year and the average price per book. Code the constructor, accessors, mutators, toString and equals method of the super class Store and the subclass Book Store; In the Book Store class, also code a method returning the average taxes per year....
Write a Python class to represent a LibraryMember that takes books from a library. A member...
Write a Python class to represent a LibraryMember that takes books from a library. A member has four private attributes, a name, an id, a fine amount, and the number of books borrowed. Your program should have two functions to add to the number of books and reduce the number of books with a member. Both functions, to add and return books, must return the final number of books in hand. Your program should print an error message whenever the...
Assume that attributes with the same name in different relations represent the same domain and that...
Assume that attributes with the same name in different relations represent the same domain and that the primary key attributes in each relation are underlined. Answer the following questions given the relational schema below: R(A,D) S(A,B,C,D) T(C,D,A,H) List all potential foreign keys in the three relations. (1 mark) List all superkeys of S. (1 mark) List all candidate keys of T. (1 mark) What is the degree and cardinality of S? (1 mark) If the cardinality of T is N,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT