Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need to implement all methods in this class. There is code I currently have at the bottom public class TVStorage { Television[] tvs =

I need to implement all methods in this class. There is code I currently have at the bottom

image text in transcribed

public class TVStorage { Television[] tvs = new Television[5]; public TVStorage() { } // TODO: Implement this method! // If the location is invalid (negative, or too large) do nothing. // If the parameter is null (and the location is ok), then replace // the object reference in the array with null public void StoreTV(int iLocation, Television tvToStore) { } // TODO: Implement this method! // If the location is invalid (negative, or too large) return null. public Television GetTV(int iLocation) { return new Television(); // odd, but will guarantee all tests fail, to start } // TODO: Implement this method! // If a given slot in the array is non-NULL, then call .Print on it // otherwise, print out "Slot X is null", where X is the slot index. public void PrintAllTVs() { } }

1. Implement all the methods on the TVStorage class. A. The constructor should do any initialization that needs to be done. Each TVStorage class should be able to store exactly 5 Television objects. 1. StoreTV should store the given Television object into the specified array location A. If the location is invalid (negative, or too large), then this method should do nothing B. Note that if the location is valid, then this method always store the given tvToStore into the array, even if the tvToStore parameter is null 2. GetTV should return the Television object (including, possibly, the null value) at the specified index, unless that index is invalid (negative, or too large) A. If the index is invalid, then it should return null 3. PrintAlLTVs should call Print on all non-null object references in the array, and should print "Slot X is null" when it encounters a null array slot (where X is replaced with the slot number) 1. You may want to run the sample code that has been provided to you, and confirm that it produces the above, example output. You can do this by this running the code in the RunExercise method of the TVStorage_Demonstration class. A. That code should produce the following output: Slot 0 is null Slot 1 is null Slot 2 is null Slot 3 is null Slot 4 is null Is t2 null? (It should be) True Slot 0 is null Slot 1 is null Brand: Brand X Price: 1000.00 Size:42.00 Slot 3 is null Brand: Brand Y Price:2000.00

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

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions

Question

which of the following is true about plagarisn detection software

Answered: 1 week ago

Question

What magazine and ads did you choose to examine?

Answered: 1 week ago