Please use python Programming Language:
Select one of the following topics:
Create a class based on your chosen topic. Make sure to include at least four attributes of varying types, a constructor, getters/setters for each attribute w/input validation, a toString, a static attribute, and a static method.
Then, create a function (outside of your class) that connects to a text file which should contain the attributes of several objects. Read the data from the file, use the data to instantiate your objects, then return them in a list.
In main(), call your function and demonstrate some methods of object from the returned list.
Note: Please use python Programming Language.
Python Program:
class Account:
""" Account class """
# Static variable
bank = 'ABC Corporation'
def __init__(self, id=0, name="", bal=100,
intRate=0):
""" Default Constructor """
self._id = id;
self._name = name;
self._bal = bal;
self._intRate = intRate;
def setId(self, id):
""" Setter method for id """
self._id = id;
def getId(self):
""" Getter method for id """
return self._id;
def setName(self, name):
""" Setter method for name
"""
self._name = name;
def getName(self):
""" Getter method for name
"""
return self._name;
def setBal(self, bal):
""" Setter method for balance
"""
self._bal = bal;
def getBal(self):
""" Getter method for balance
"""
return self._bal;
def setIntRate(self, intRate):
""" Setter method for interest rate
"""
self._intRate = intRate;
def getIntRate(self):
""" Getter method for interest rate
"""
return self._intRate;
def __str__(self):
""" Overriding toString method
"""
return ("ID: " + str(self._id) +
"\nName: " + self._name + "\nBalance: " + str(self._bal) +
"\nInterest Rate: " + str(self._intRate))
@staticmethod
def getBank():
return
Account.bank
# Main function that creates objects from text file
def main():
accObjs = []
# Opening file for reading
with open("d:\\Python\\acc.txt") as fp:
# Iterating over line by line
for line in fp:
cols =
line.strip().split()
# Creating
account object
aObj =
Account(int(cols[0]), cols[1], float(cols[2]),
float(cols[3]))
# Adding to
list
accObjs.append(aObj)
print("\nBank Name: " + Account.getBank() +
"\n\n")
# Printing objects
for aObj in accObjs:
print(aObj)
print("\n")
# Main function calling
main()
________________________________________________________________________________________________
Sample Run:
Input File: acc.txt
8073 Nicholas 23750.0 6.2
245 Paul 1236.5 7.5
3381 Tom 1427.8 12.0
2813 Nate 1885.0 4.7
Please use python Programming Language: Select one of the following topics: Band Character Account Create a...
can you please solve #2, 3 and 4 ? please by using Python 3 8:34 PM € Assignment Details 6202-COSC-2436-Programming Fundamentals i company TOITOWS: Ask the customer have his into G unter his own . If you SOLO u ld email. If Ask hinto anto TV unit l emname, .). Append the total Hoe to his 2. Create a class called person with name, phone and email as private attributes. Create a customer class as a sub class of person...
Please use netBeans Exercise 4:A librarian needs to keep track of the books he has in his Library.1. Create a class Book that has the following attributes: ISBN, Title, Author, Subject, and Price. Choose anappropriate type for each attribute.2. Add a static member BookCount to the class Book and initialize it to zero.3. Add a default constructor for the class Book. Increment the BookCount static member variable and an initialization constructor for the class Book. Increment the BookCount in all constructors.4....
Python programming I need help with the following: Create a class Vehicle. The class should have name, weight, fuel, number of wheels and move attributes/methods. Create child class that are semi, car, sail boat and bicycle. Give the class the ability to have a constructor that sets the name. Have the other attributes hard coded to suit the vehicle. Give each a way of speaking their attributes as well as the type of animal. For example “Hi I am Lightening...
using CSCI300 java Given the following UML Class Diagram Club_Card # card_num : String # name : String # age: int # year: int + Club_Card (all parameters) + Setters & Getters + toString() : String + equals(x: Object): boolean [10 pts] Define the class Club_Card, which contains: 1. All arguments constructor which accepts all required arguments from the main and instantiate a Club_Card object. 2. Set & get method for each data attribute. 3. A toString() method which returns...
please use basic programming language and explain with comment lines .for Thonny(python) format. Duplicate elimination Create a function named unique that receives a list and returns a (possibly shorter) list containing only the unique values in sorted order. Test your function with the list of numbers and list of strings that given in the sample output. Sample Output Original list of numbers [11, 11, 2, 2, 7, 7, 5, 5, 3, 3] New list after calling unique function [2, 3,...
I need some help with programming this assignment. Programming Assignment 6: A Python Class, Attributes, Methods, and Objects Obiectives .Be able to write a Python class Be able to define class attributes Be able to define class methods .Be able to process input from a text file .Be able to write an application using objects The goal of this programming assignment is to develop a simple image processing application. The application will import a class that creates image objects with...
*Python* INTRODUCTION: The goal of this programming assignment is to enable the student to practice object-oriented programming using classes to create objects. PROBLEM DEFINITION: Write a class named Employee that holds the following data about an employee in attributes: name, IDnumber, department, jobTitle The class should have 8 methods as follows: For each attribute, there should be a method that takes a parameter to be assigned to the attribute. This is known as a mutator method. For each...
Write a python program using Object Oriented and do the following: 1. create class "cat" with the following properties: name, age (create constructor method: def __init__) 2. create class "adopter" with the following properties: name, phone 3. create class "transaction" with these properties: adopter, cat (above objects) cat1 = "puffy, 2" adopter1 = "Joe, 123" Test your program: Joe adopts puffy. Print: "Per Transaction 1 <joe> has adopted <puffy>" this can only be done with object oriented programming, no way...
Please use python 3 programming language Write a function that gets a string representing a file name and a list. The function writes the content of the list to the file. Each item in the list is written on one line. Name the function WriteList. If all goes well the function returns true, otherwise it returns false. Write another function, RandomRange that takes an integer then it returns a list of length n, where n is an integer passed as...
(JAVA) Use the Pet.java program from the original problem (down below) Compile it. Create a text file named pets10.txt with 10 pets (or use the one below). Store this file in the same folder as your “class” file(s). The format is the same format used in the original homework problem. Each line in the file should contain a pet name (String), a comma, a pet’s age (int) in years, another comma, and a pet’s weight (double) in pounds. Perform the...