Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

It is mandatory that you develop your code using Python 3 and the syntax presented in lectures (e.g. additional code annotations introduced in the latest

image text in transcribed

It is mandatory that you develop your code using Python 3 and the syntax presented in lectures (e.g. additional code annotations introduced in the latest versions of Python are NOT allowed). 1. Do you remember our fruit type from lab 3? You need to implement this ADT again, this time in Python. In the text editor of your choosing create a file fruit.py and define class FruitType, with its properties and methods described below - make sure you use the exact same names as indicated in the description. Test all methods below your class definition (i.e. in the same file - we will use your code to verify you tested thoroughly and then run it to verify correctness). No credit for un-tested functionality, as in Python the code is not verified until run-time. a. constructor that takes three parameters that are to be used for name, weight, pricePerPound (in this order), and assigns their values to private fields; the constructor should provide default values of "" and 0 (do NOT worry about invalid parameter contents) b. a class level field that counts the number of FruitType objects called numoffruits (needs to be updated inside the constructor; make sure you test it as well) c. one setter (called set_name) and one getter (called get name) for name only d. __str method that returns a fruit object as a string - format the string in some fashion, e.g.: apple, 250 pounds, 4.25 USD per pound (although your actual numerical values may be longer than two decimal digits) e. instead of the add method, overload the addition operator and implement the addition logic in it from lab 3, i.e. the method takes another FruitType object and returns a new FruitType object if the names of the two objects are identical (follow the same logic as in lab 3) or None if the object names differ

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