Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have been tasked with writing a program that opens a file listing bike stations and some data about each bike station. Each bike station

I have been tasked with writing a program that opens a file listing bike stations and some data about each bike station. Each bike station is separated by line. Below are the instructions. This is my first time writing code from scratch, and I am a little overwhelmed. Any help is appreciated!

Step 1: Select a set of Bike Stations to take data for

  • Go to Assignment: Choose Set of Bike Stations to Collect Data For and follow the instructions on the page to choose the five Bike Stations you collect data for.

Step 2: Write an BikeStation class that demonstrates the following aspects of OOP in Python:

  1. Create a basic class that can hold all relevant Bike data for an individual bike station (see above).
    • As with a database, you don't normally want to have calculated values stored in your objects because it could cause data integrity issues if, for example - you update the available_bikes when a bike is returned but forget to update percent_full.
    • As such, you BikeStation class should only include the data values to uniquely specify the current state (number bikes available, number slots in the station).
  2. Appropriately create a constructor to set all data values .
  3. Use the @property decorator to make at least one property in your BikeStation class private.
  4. Use the @???.setter method to validate the private property in some way (e.g. check if its numeric, change it's data type, change it's length) before setting its value.
  5. Create one or more regular class methods to CALCULATE other relevant bike station values from the data attributes you are storing as a part of the class.
  6. Override the __str__ method to print a string representation of a BikeStation that looks like the String below (note that the format of the date string is different than it is in the data file): Paulina St & Howard St had 10 bikes on Mon Nov 16 11:55:55 2020

Step 3: Write a second class called Point, Position or Time to store one or more pieces of BikeStation data.

  • The class could store latitude & longitude OR timestamp
  • You should use this class in the BikeStation class instead of storing the vales as primitive data types

You may use the Author and Article classes presented in lecture as a starting point for these classes.

Step 4: Testing you classes using data from the data file bdata.txt

  1. Prompt for a file name (bdata.txt):
  2. Open that file and read through the file
  3. Display a custom error message if the file does not exist
  4. Use an appropriate String method find lines for the BikeStations you were assigned - e.g. lines that contain: "id": "###" (where (###) is the number for one of the Bike Stations you were assigned).
  5. Once you have found lines of, you can pull the BikeStation data out from the the line by splitting the line on a ", " and then splitting the string a second time using a colon.
  6. Create a new BikeStation object and add them to a list.
  7. Print the BikeStation Object
  8. You code should be efficient (you should not have to open the file multiple times NOR should you have to loop through the data more than once).
  9. Print out the total number of Bikes available for each of the five Bike Stations you were are gathering data for after the file has been completely read.
  10. Print out the total number of empty bike docks available for each of the five Bike Stations you were are gathering data for after the file has been completely read.

Your output should look something like this:

Paulina St & Howard St had 10 bikes on Mon Nov 16 11:55:55 2020 Clark St & Jarvis Ave had 1 bikes on Mon Nov 16 11:55:55 2020 Greenview Ave & Jarvis Ave had 3 bikes on Mon Nov 16 11:55:55 2020 Bosworth Ave & Howard St had 1 bikes on Mon Nov 16 11:55:55 2020 Eastlake Ter & Rogers Ave had 2 bikes on Mon Nov 16 11:55:55 2020 Stations: [515, 517, 520, 522, 523] Bikes Available 17 Docks Available 58

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_2

Step: 3

blur-text-image_step3

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

More Books

Students also viewed these Databases questions

Question

Explain different methods used for management accounting reporting

Answered: 1 week ago