Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Design and implement the following interface and class hierarchy ( shown in Figure 1 ) in C# to demonstrate the relationships and functions among various

Design and implement the following interface and class hierarchy (shown in Figure 1) in C# to
demonstrate the relationships and functions among various musical instruments in a typical
musical instrument shop.
Sheridan College Assignment 1
Page 2 of 5
Figure 1: IFixable and IPlayable are two interfaces. MusicalInstrument,
StringFamily, PercussionFamily, and WoodwindFamily are all abstract classes.
Guitar, Harp, Drum, Xylophone, and Flute are concrete classes.
Most information handled and/or returned by interface and abstract class methods are
presented in Table 1. Use this table for information to be returned by your method
implementations within respective class.
Table 1: Information on musical instruments
Instrument Make
sound
Price How to play How to fix Pitch Type
Drum vibrating
stretched
membrane
$349.50 by hitting the
membrane
replace the
membrane
Sonic pitch
Flute guiding a
stream of
air
$74.90 by blowing into
the flute
N/A: it cannot be
fixed
Fundamental
pitch is middle C
Guitar vibrating
strings
$199.00 by strumming
the strings
replace the strings Low to high
pitch
<>
IFixable
+HowToFix(): string
+MakeSound (): string
+GetPrice(): double
+GetPitchType(): string
MusicalInstrument
<>
IPlayable
+HowToPlay(): string
Harp
StringFamily
Guitar Flute
PercussionFamily WoodwindFamily
Drum Xylophone
Sheridan College Assignment 1
Page 3 of 5
Harp vibrating
strings
$255.00 with the thumb
and
first three
fingers
replace the strings Has seven levels
of pitch
Xylophone through
resonators
$49.00 with two
mallets
replace bars Each bar
produces
different pitch
Your implementation should:
i)[Requirement 1] receive the price value for each instrument from the user to create an object
of that instrument (other information for that instrument object e.g., make sound, how to
play, how to fix, and pitch type can be hard coded as per Table 1).
ii)[Requirement 2] display How to Play, How to Fix, Pitch type and Price information for the most
expensive instrument through comparing objects of all instruments.
iii)[Requirement 3] display the names of all instruments (Drum, Flute, Guitar, Harp, Xylophone)
in descending order of price. You must override the ToString() method to display the name of
an instrument.
iv)[Requirement 4] receive an instrument family name (e.g., String family, Percussion family or
Woodwind family) from the user, and display how each instrument of that given family makes
sound.
Your implementation must also satisfy following requirements:
v)[Requirement 5] You must demonstrate the use of IComparable interface and implement
its CompareTo() method (or IComparer interface and implement its Compare() method)
to find the instrument object with the highest price and sort them.
vi)[Requirement 6] You must demonstrate the use of one or more Collection (e.g., a List of type
MusicalInstrument to hold objects of each concrete type of musical instrument). Use the
CompareTo() method that you may have overridden in MusicalInstrument class (or
Compare() method that you might have implemented in a separate helper class) to find the
instrument object with the highest price and sort them in the collection. No operation on the
instruments should be hard coded meaning all operations must be done programmatically.
vii)[Requirement 7] Your program must demonstrate proper modularization of code, C# industry
standard with proper comments, indentations, and naming convention.
viii)[Requirement 8] You must include the following information as commented at the beginning
of your main class file.
Assignment: 1
Name:
Id:
Sheridan College Assignment 1
Page 4 of 5
ix)[Requirement 9] You must test your application for multiple runs with different price
values for all instruments. Change the price value for each instrument to show that your
application works even if the price of instruments is updated. Take screenshots for at least
two runs showing inputs/outputs for Requirements 1-4.
x)[Requirement 10] In addition, you MUST submit all the screenshots as specified in
Submission Guideline.
Sample Output: On the above information of musical instruments in Table 1, the output of a test
run should be as follows:
--: Requirement 1 :--
Enter the price for Drum: <349.5>
Enter the price for Flute: <74.9>
Enter the price for Guitar: <199>
Enter the price for Harp: <254>
Enter the price for Xylophone: <49>
--: Requirement 2 :--
The most expensive instrument is: Drum
Drums cost is: $349.50
Drum is played: by hitting the membrane
Drum fixing: replace the membrane
Drum pitch type: Sonic pitch
--: Requirement 3 :--
Instruments in price descending order:
[Drum, Harp, Guitar, Flute, Xylophone]
--: Requirement 4 :--
Enter an instrument family:
Xylophone makes sound through resonators.
Drum makes sound vibrating stretched membrane

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

The Database Experts Guide To Database 2

Authors: Bruce L. Larson

1st Edition

0070232679, 978-0070232679

More Books

Students also viewed these Databases questions