Answered step by step
Verified Expert Solution
Question
1 Approved Answer
use only python programming language. 5. This question is centered on two types of gems namely a 'Sapphire' and a 'Topaz'. 'Sapphire' is blue, has
use only python programming language.
5. This question is centered on two types of gems namely a 'Sapphire' and a 'Topaz'. 'Sapphire' is blue, has an oval shape, and is priced at USD 150 while 'Topaz' is yellow, and has a heart shape, and is priced at USD 220. Write a Python application as per the instructions provided in parts i. ii. iii. and iv. to display the details of the two gems as follows: The price of Oval shaped Blue Sapphire is USD 150. The price of Heart shaped Yellow Topaz is USD 220. i. Create a class called 'Gem' with four (4) private variables namely 'gem_type', 'shape', 'color', and 'price'. (2 Marks) ii. Include four (4) 'setters' and four (4) 'getters' in the 'Gem' class with appropriate arguments to set data into the fields 'gem_type', 'shape', 'color', 'price' and to get those data from the four (4) fields respectively. Also, include a reusable method named 'showDetails()' that can display the two given outputs by getting the set data from the fields. (6 Marks) iii. Create two subclasses of the 'Gem' class called 'Sapphire' and 'Topaz', for the purpose of creating objects. (4 Marks) iv. Create two individual objects (one from each) of the subclasses 'Sapphire' and 'Topaz' respectively and use them to set data into the fields, get data from the fields and call the method 'showDetails()' to get the required output. (4 Marks) v. Indicate the code segments where Encapsulation, Inheritance, and Polymorphism were implemented by inserting appropriate comments. Also, discuss the advantages gained by incorporating those features into the code. (4 Marks)
Step by Step Solution
★★★★★
3.54 Rating (154 Votes )
There are 3 Steps involved in it
Step: 1
Answer 1 The system or physical system A physical system is a collection of physical objects In phys...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started