Question

Written in python using puTTy!!

i'm having a lot of trouble with this, will upvote!

also here is the address.csv file

Name,Phone,Email,Year_of_Birth
Elizi Moe,5208534566,emoe@ncsu.edu,1978
Ma Ta,4345667345,mta@yahoo.com,1988
Diana Cheng,5203456789,dcheng@asu.edu,1970

ACTIVITY I

Implement in Python the Subscriber class modeled by the UML diagram provided below. Save in a file called MyClasses.py

Subscriber

name: string

yearOfBirth: int

phone: string

email: string

getName()

getAge()

getPhone()

getEmail()

Write a test program that does the following:

Read the file addresses.csv.
For each record, create an object with the information in the file. Note that the file has 3 records, so 3 objects must be dynamically created.
Print the name, email, and age in a tabulated format as shown below

Name                     Email                           Age

Elizi Moe               emoe@ncsu.edu          40

Ma Ta                    mta@yahoo.com          30

Diana Cheng          dcheng@asu.edu         48

ACTIVITY II

Modify your Subscriber class so that:

The current year is a global variable, taken from the user
The program keeps a count of the number of subscribers instantiated

You must print the same information as in the previous exercise, and in the same format; but also the number of subscribers in the form: “There were xxx subscribers in the file”.

ACTIVITY III

Implement in Python the Subscriber_v2 class modeled by the UML diagram provided below. Save in a file called MyClasses.py

Subscriber_v2

- name: string

- age: int

- phone: string

- email: string

+ getName()

+ getAge ()

+ getPhone()

+ getEmail()

+ setName(name:string)

+ setAge(birthYear:int)

+ setPhone(ph:string)

+ setEmail(email:string)

Write a test program that does the following:

Read the file addresses.csv.
For each record, create an object with the information in the file. Note that the file has 3 records, so 3 objects must be dynamically created.
Print the name, email, and age in a tabulated format as shown below

Name                     Email                           Age

Elizi Moe               emoe@ncsu.edu          40

Ma Ta                    mta@yahoo.com          30

Diana Cheng          dcheng@asu.edu         48

There were 3 subscribers in the file

ACTIVITY IV

Design a class named Stock (add to the file MyClasses.py) to represent a company’s stock that contains:

A private string data field named symbol for the stock’s symbol
A private string data field named name for the stock’s name
A private float data field named previousClosingPrice that stores the stock price for the previous day
A private float date field names currentPrice that stores the stock price for the current time
A constructor that creates a stock with the specified symbol, name, previous price, and current price
A get method for returning the stock name
A get method for returning the stock symbol
Get and set methods for getting/setting the stock’s previous price
Get and set methods for getting/setting the stock’s current price
A method names getChangePercent() that returns the percentage changed from previousClosingPrice to currentPrice

(1) Draw a UML diagram for the class, and then implement the class

(2) Write a test program that creates a Stock object with the stock symbol INTC, the name Intel Corporation, the previous closing price of 20.5, and the new current price of 20.35, and display the price-change percentage

ACTIVITY V

Implement the subclass Rectangle of the the superclass GeometricObject defined by the UML diagram below

GeometricObject -color: str The color of the object (default: green) Indicates whether the object is filled with a color (default: True) filled: bool GeometricObject(color: str, filled Creates a GeometricObject with the specified color and filled boo1) getColorO: str setColor(color: str): None isFilledO: bool setFilled(filled: boo1): None values Returns the color. Sets a new color. Returns the filled property. Sets a new filled property Returns a string representation of this object str__O: str Circle Rectangle -radius: float -width: float -height: float Rectangle(width: float, height: float, color: Circle(radius: float, color: str, filled: bool) getRadius O: float setRadius (radius: float): None getArea O: float getPerimeterO float getDiameterO: float printCircleO: None string, filled: bool) getWidthO: float setwidth (width: float): None getHeightO: float setHeight(height: float): None getAreaO: float getPerimeterO float

Sample Run:

A rectangle color: green and filled: True

The area is 8

The perimeter is 12

0 0
Add a comment Improve this question Transcribed image text
Answer #1

ACTIVITY I and II

class Subscriber():
current_year=0
subscriber_count=0
def __init__(self,name,year_of_birth,phone,email):
self.name=name
self.year_of_birth = year_of_birth
self.phone=phone
self.email=email
Subscriber.subscriber_count+=1

def getName(self):
return self.name

def getAge(self):
return Subscriber.current_year-self.year_of_birth

def getPhone(self):
return self.phone

def getEmail(self):
return self.email


def main():
persons=[]
Subscriber.current_year=2018
sub1=Subscriber('Elizi', 1978, '1234567890', 'emoe@ncsu.edu')
sub2=Subscriber('Ma Ta', 1988, '1234567890', 'mta@yahoo.com')
sub3=Subscriber('Diana Cheng', 1970, '1234567890', 'dcheng@asu.edu')
persons.append(sub1)
persons.append(sub2)
persons.append(sub3)
print('{0:<15}{1:<15}{2:>4}'.format("Name","Email","Age"))
for person in persons:
print('{0:<15}{1:<15}{2:>4}'.format(person.getName(),person.getEmail(),person.getAge()))
print('\nThere were', Subscriber.subscriber_count ,'subscribers in the file')
main()

OUTPUT:

ige ELAS Ha Ta Dians Cheng lass.eds

Add a comment
Know the answer?
Add Answer to:
Written in python using puTTy!! i'm having a lot of trouble with this, will upvote! also...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Python only please, thanks in advance. Type up the GeometricObject class (code given on the back...

    Python only please, thanks in advance. Type up the GeometricObject class (code given on the back of the paper). Name this file GeometricObjectClass and store it in the folder you made (xxlab14) 1. Design a class named Rectangle as a subclass of the GeometricObject class. Name the file RectangleClass and place it in the folder. 2. The Rectangle class contains Two float data fields named length and width A constructor that creates a rectangle with the specified fields with default...

  • Type up the GeometricObject class (code given on the back of the paper). Name this file Geometric...

    Python only please, thanks in advance. Type up the GeometricObject class (code given on the back of the paper). Name this file GeometricObjectClass and store it in the folder you made (xxlab14) 1. Design a class named Rectangle as a subclass of the GeometricObject class. Name the file RectangleClass and place it in the folder. 2. The Rectangle class contains Two float data fields named length and width A constructor that creates a rectangle with the specified fields with default...

  • You have just been hired as an analyst for an investment firm. Your first assignment is...

    You have just been hired as an analyst for an investment firm. Your first assignment is to analyze data for stocks in the S&P 500. The S&P 500 is a stock index that contains the 500 largest publicly traded companies. You have been given two sources of data to work with. The first is an XML file that contains the Symbol (ticker), company name, sector, and industry for every stock in the S&P 500, as of summer 2016. The second...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT