Create a new class called Author. Create a regular class, not a dataclass. An Author has...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Create a new class called Author. Create a regular class, not a dataclass. An Author has a name, and a list of books published. When you create a new Author, they don't have any books. So create an empty books list attribute in the _init_method. Your Author class should have a publish method, which takes the title of a book as an argument. Add the title of this book to this object's books list. Add astr method that returns a String with the author's name, and the names of all of their book's titles. Write a main function to test your class, create some example authors, and publish some example books. Part 2: Author class - no duplicate books Start with the program from part 1. In this version, an author can't publish two books with the same name. When the publish method is called, print an error message if the book given has the same name as a book currently in the books list. (In other words, make sure the Author object's book list doesn't already contain that name). In your breakout rooms: there's more than one way to solve this - can you come up with two different solutions? Part 3: Student dataclass. Type in the dataclass code from the slides/video. You would have done this before class. Add one more field: gpa, a float. Write a main function to create some example Student objects with some example names, college_id and GPA values. Verify you can read the name, college ID and GPA for an example student. Verify when you print an example student, the GPA is included. Add some comments in your code to compare the dataclass version to the "traditional" version. Create a new class called Author. Create a regular class, not a dataclass. An Author has a name, and a list of books published. When you create a new Author, they don't have any books. So create an empty books list attribute in the _init_method. Your Author class should have a publish method, which takes the title of a book as an argument. Add the title of this book to this object's books list. Add astr method that returns a String with the author's name, and the names of all of their book's titles. Write a main function to test your class, create some example authors, and publish some example books. Part 2: Author class - no duplicate books Start with the program from part 1. In this version, an author can't publish two books with the same name. When the publish method is called, print an error message if the book given has the same name as a book currently in the books list. (In other words, make sure the Author object's book list doesn't already contain that name). In your breakout rooms: there's more than one way to solve this - can you come up with two different solutions? Part 3: Student dataclass. Type in the dataclass code from the slides/video. You would have done this before class. Add one more field: gpa, a float. Write a main function to create some example Student objects with some example names, college_id and GPA values. Verify you can read the name, college ID and GPA for an example student. Verify when you print an example student, the GPA is included. Add some comments in your code to compare the dataclass version to the "traditional" version.
Expert Answer:
Answer rating: 100% (QA)
Part 1 Author class class Author def initself name selfname name selfbooks create an empty list attribute to store the books def publishself title if ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Two charges of 1 C each are separated 10 cm apart. what will be the potential energy between them?
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Umida Ltd is considering acquiring Trinity Ltd. Both companies are all-equity firms. Umida and Trinity have 5 million and 6 million shares outstanding respectively. Umida generates $2 million in...
-
Error and Change in Estimate Depreciation Tarkington Co. purchased a machine on January 1, 2007, for $440,000. At that time it was estimated that the machine would have a 10-year life and no salvage...
-
Sketch the graph of r = 5 sin and r = 2 + sin and find their points of intersection.
-
For several years running, the Over-the-Top Buffet, a Las Vegas Burburr all-you-can-eat attraction, has been voted the best buffet by several publications. The Over-the-Top Buffet offers a seemingly...
-
The following information is extracted from the accounting records of the Shelton Corporation at the beginning of 2007: Accounts Receivable .........$63,000 Allowance for Doubtful Accounts.....1,400...
-
19.A radioactive -emission. A detector records n -particles in 2s and by next 2s (accumulatively) it records 1.1 n -particle. Number of -particles recorded by detector after a long time, is (1) 11n...
-
Landover Corporation is looking for a larger office building to house its expanding operations. It is considering two alternatives. The first is a newly constructed building at a cost of $6 million....
-
Discuss the various Schedule A Itemized Deductions, the Standard Deductions for each Filing Status, the Additional Standard Deduction, and those taxpayers eligible for the Qualified Business Income...
-
We often assign our student groups to observe and gather information about other real-life groups. One of our groups observed another group of students working on a project for a marketing class....
-
Carla, our city councilwoman, chose to accept the group norm of meeting as long as it took to complete the groups work. However, there are pros and cons to that norm. Yes, the work was not permitted...
-
Assume you are on a student judicial committee charged with deciding the punishment of students who have violated your institutions rules and policies. Rob, the student whose case the committee is...
-
You and your group have been working on your panel presentation about the death penalty for several weeks, with one week to go before you are responsible for conducting the panel discussion in your...
-
According to Carl Hiaasen in Team Rodent: How Disney Devours the World,* Disneys venture in France, Euro-Disney, got off to a slow start when it opened in 1992. Disney executives decided to import...
-
A liquid in the lab has a density of 1.17 g/cm. What is the volume in liters of 3.02 kg of the liquid?
-
On October 31 Juanita Ortega, owner of Outback Guide Service, received a bank statement dated October 30. Juanita found the following: 1. The checkbook has a balance of $2,551.34. 2. The bank...
-
Klandon Company manufactures decorative rocks for aquariums. Kim Klandon is preparing the budget for the quarter ended June 30. She has gathered the following information. 1. Klandons sales manager...
-
Classify each of the following items from National Beverage Corp.s statement of cash flows as a source or use of cash, and identify the section of the statement that each appearedin. Source or...
-
King Designs is a leading product design firm that serves consumer products companies, primarily in the area of packaging design. King's customers are seeking product packaging solutions that are...
-
Sustainability involves more than just the impact of actions on the environment. The triple bottom line recognizes that a company has to measure its impact on its triple bottom line for its long-term...
-
Bryan Haas has his own electronics retail chain, TechnoGeek. His stores sell computer parts, audiovisual equipment, consumer electronics, and related items. Custom computer building and electronics...
-
Shula Perot is the new controller for EduTechno Software, which develops and sells educational software. Shortly before the December 31 fiscal year-end, Nico Cattrall, the company president, asks...
Study smarter with the SolutionInn App