Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is a python assignment. For the question there is a template, see above pic. Also, for the question 'the instance of Marbles' is a

image text in transcribed

image text in transcribedThis is a python assignment. For the question there is a template, see above pic. Also, for the question 'the instance of Marbles' is a typo, it is supposed to be 'the instance of Marble'. The class Marble is completed and on top of the class named Jar, please use it to answer the question. The out put should resemble the top picture

2: Implement a class named Jar (template provided) that manages instances of Marbles. See the docstrings and screenshot below for behavior. >>> m=Marble() >>> jar=Jar() >>> jar. addMarble (m) >>> m <_main__. marble object at> >>> str (m) 'grey' >>> jar.getColors () ['grey'] >>> m=Marble () >>> m.getColor() 'green' >>> jar. addMarble (m) >>> jar.getColors() ['grey', 'green'] >>> for marble in jar: print (marble) 1 grey green >>> jar.getCount() 2 >>> jar.getColorCount('grey') 1 >>> jar.getColorCount('green') 1 >>> jar.getColorCount(yellow) 0 >>> | The end of the template file has a way to automate the testing. This is my output: - RESTART: C:\Users\azoko OneDrive - DePaul University Documents Teaching cac 242Bvening class - Section 506 Week 4 Lab Marb ledar.py ['red', 'green', 'Yellow', 'blue', 'red', 'green', 'red', 'green', 'green', 'red', 'black', 'green', 'yellow', 'red', 'grey'. 'blue', 'green', 'green', 'green', 'green', 'blue, yellow, blue, red, grey', 'red', 'blue', 'red', 'red', grey, cen' yellow, black green :: Tradi grey!.. 'black'. red "greybu Diue', 'blue', 'yellow', 'red', 'grey', '61 uw', 'grey': yellow, red, blue': 'blue': 'blue', 'blue' 'blue', 'blue', 'blue', yellow, red green 'grey', 'green', 'blue', 're be yellow'. Tron', 'red', 'euy grey', 'black', 'blue', 'red'. yellow, red , '' 'grey, black ki, green green red , yellow, green: grey. Fred'grey 'blue', 'blue', 'black', 'black', 'black', 'green' Total red marbles = 12 cluxx Mst: 1c1!! der nic_lt: Selector and candlere: eccles! der getColoriselt: ENLUN l.culor der sty_(.ri: return ret.no sherimi_ll pass det addstarbel: add a nable to the SHL Colli get a count o nurtles der getColor:geti: HH! Nu all the more pass der getColor cuntis.t, color): get count on how vany naxbles of a sperite color are in the day return an iterator 1-Jaro Triin TH, MH: j..coaxbl Murbloc) print(j.getColora! printtal rec rathlms : 0'.Forratij.getColor) Ln: 13 Col: 25

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: 3

blur-text-image

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

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

3rd Edition

0128012757, 978-0128012758

More Books

Students also viewed these Databases questions