You are to create an application that will read data from a file and store it...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
You are to create an application that will read data from a file and store it in a collection of objects. You will create a class called Bookstore which will maintain a list of Book objects (the second class you will create). Methods of Bookstore: load - takes a string representing a filename, opens the file, reads the data, splits it into components, trims any extra whitespace and converts the data where necessary, and adds Book objects to the list accordingly. Don't forget to close the file when done. add - takes the following parameters: title, subtitle, edition, authors (edition is always an integer, everything else is a string), creates a Book from it, and then adds that book to the list. remove - takes a title and edition, finds the first book in the list that matches the criteria, and removes it from the list, returning True. If it cannot find the book, it returns False (Hint: you can assume that you won't find the item that is, set a local variable to False - then, if you find it, set that same variable to True. Regardless, at the end of the problem, you return the status, which will be False unless you found a match.) _str_- returns a string which is a formatted list of books, looking like the following: Big Java Late Objects 2 Cay Horstmann Digital Design 6 Mano & Ciletti Cloud Commuting Of course, it's obvious there are more than two books. Note that if the subtitle is blank, it is NOT printed. You ask a Bookstore to stringify itself with the str function, which you have used on things like integers when printing. This method works by asking each Book object to stringify itself (using the str function). After each book, a newline is printed (to separate the books). . The constructor of Bookstore sets up the empty list as an instance variable and calls the load method on a supplied filename. Methods of Book: Book requires: its constructor, which takes the title, subtitle, edition, and author (remember, the edition is an integer), and stores them in instance variables. its_str_ method, which returns the Book in string form accessors (getters) for each of the instance variables (for example, get_title would get the title) You are to create an application that will read data from a file and store it in a collection of objects. You will create a class called Bookstore which will maintain a list of Book objects (the second class you will create). Methods of Bookstore: load - takes a string representing a filename, opens the file, reads the data, splits it into components, trims any extra whitespace and converts the data where necessary, and adds Book objects to the list accordingly. Don't forget to close the file when done. add - takes the following parameters: title, subtitle, edition, authors (edition is always an integer, everything else is a string), creates a Book from it, and then adds that book to the list. remove - takes a title and edition, finds the first book in the list that matches the criteria, and removes it from the list, returning True. If it cannot find the book, it returns False (Hint: you can assume that you won't find the item that is, set a local variable to False - then, if you find it, set that same variable to True. Regardless, at the end of the problem, you return the status, which will be False unless you found a match.) _str_- returns a string which is a formatted list of books, looking like the following: Big Java Late Objects 2 Cay Horstmann Digital Design 6 Mano & Ciletti Cloud Commuting Of course, it's obvious there are more than two books. Note that if the subtitle is blank, it is NOT printed. You ask a Bookstore to stringify itself with the str function, which you have used on things like integers when printing. This method works by asking each Book object to stringify itself (using the str function). After each book, a newline is printed (to separate the books). . The constructor of Bookstore sets up the empty list as an instance variable and calls the load method on a supplied filename. Methods of Book: Book requires: its constructor, which takes the title, subtitle, edition, and author (remember, the edition is an integer), and stores them in instance variables. its_str_ method, which returns the Book in string form accessors (getters) for each of the instance variables (for example, get_title would get the title)
Expert Answer:
Answer rating: 100% (QA)
ANSWER Below is the Python code that implements the Book and Bookstore classes according to your req... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
BONUS (5 points) You plan to retire at 65 and want an annuity that will pay you $3700 a month for 30 years from an account that pays 3.75% interest. How much needs to be in your account?
-
Using priority queues to implement a loan approval system for a financial institute that funds startups. Problem: Our financial institute receives many loan applications and rejects them only if the...
-
Create a java class FileHandler that has a parameter constructor that takes 2 strings - a read from and write to filename. Create a private data member that is a file reading scanner object reference...
-
1. Two football fans are listening to the Grey Cup game on the radio, one in Montreal, where the game is being played, the other in Vancouver, 3692 km away. How much sooner does the Montreal fan hear...
-
A two-pole, 60-Hz three-phase laboratory-size synchronous generator has a rotor radius of 5.71 cm, a rotor length of 18.0 cm, and an air-gap length of 0.25 mm. The rotor field winding consists of 264...
-
Utilizing the equipment and materials available in a typical kitchen, design an experiment to reproduce results similar to those shown in Fig. 5.12.
-
An increasing number of electronic files are secured by encryption measures for added levels of protection. Such measures may make it difficult for law enforcement officials to access computer hard...
-
Eta Corporation approaches Lily White, the CEO and sole shareholder of MuCo, regarding the acquisition of MuCo's cat toy division assets (worth $1.3 million). As selling the assets would create a...
-
65. Doubling the initial concentration of a reactant doubles t1/2 of the reaction then order of reaction is :- (1) 3 (2) 2 (3) 1 (4) Zero
-
A committee in charge of promoting a Ladies Professional Golf Association tournament is trying to determine how best to advertise the event during the two weeks prior to the tournament. The committee...
-
You, Yorkville University CPA student, are a senior accountant at BUSI 3443 LLP, a mid-size firm specializing in the audit of smaller, high-tech companies. You have recently been assigned to a new...
-
Suntharee Lhaopadchan is a Thai student who is planning a one-year stay in the United Kingdom. She expects to arrive in the United Kingdom in 8 months. She is worried about depreciation in the Thai...
-
Assume you work for Sacyr Vallehermoso SA, a Spanish company that offers construction services. The management has decided to have a long-term bond issue to fund investment in China. It is debating...
-
The spot rate of foreign exchange between the United States and the United Kingdom is $1.6117/. If the interest rate in the United States is 13 per cent and it is 8 per cent in the United Kingdom,...
-
An equity has a beta of 0.9 and an expected return of 9 per cent. A risk-free asset currently earns 2 per cent. (a) What is the expected return on a portfolio that is equally invested in the two...
-
A convertible bond with a face value of SKr10,000 has a conversion price of SKr356. What is the conversion ratio of the bond?
-
From: Mandy Summers, Production Manager Sent: October 8, 2021 12:18 PM To: Production Staff Subject: New Equipment for Sweet Creations Inc. Effective October28 (1) Our production staff at Sweet...
-
The following cost information was provided to you for analysis: September 12,000 Units Produced Costs: TIC TAC TOE TING August 10,000 P80,000 70.000 60.000 50,000 How much is the fixed cost per...
-
What statement would you use to print the phrase Hello, world and then start a new line?
-
Write a precursor to a menu-driven program. The program should display a menu offering four choices, each labeled with a letter. If the user responds with a letter other than one of the four valid...
-
Name three problems that may arise if you define a class in which a pointer member is initialized by using new. Indicate how they can be remedied.
-
A gene is a segment of DNA that contains the information to produce a functional product. The functional product of most genes is a. DNA. b. mRNA. c. a polypeptide. d. none of the above.
-
Which of the following is not a constituent of a cells proteome? a. An enzyme b. A cytoskeletal protein c. A transport protein in the plasma membrane d. An mRNA
-
The direct result of the process of transcription is the synthesis of a. DNA. b. RNA. c. a polypeptide. d. all of the above.
Study smarter with the SolutionInn App