Question: Using c# Class Design Design an inheritance hierarchy of locks , where each lock object encapsulates an integer sequence of some minimum non-zero length and
Using c#
Class Design
Design an inheritance hierarchy of locks, where each lock object encapsulates an integer sequence of some minimum non-zero length and a key which varies across objects. The integer sequence is acquired via Dependency Injection; hence, error response is expected.
A basic lock object supports client requests to reset, lock, unlock and retrieve.
- lock(x) -- returns a bool
- if locked, freezes object
- else if x>mean value of encapsulated sequence, locks object
- unlock(y) -- returns a bool unlocks the object if y appears in the encapsulated sequence
- retrieve() returns the key if unlocked
Define two descendant classes, where
lockError object is-a lock and thus operates like an lock object, except that:
- when the number of failed unlock requests exceeds a bound, the object is frozen
- a failed (but not frozen) lock(y) request adds y to the sequence
- retrieve() returns an inverted key
lockSecret object is-a lock and thus operates like an lock object, except that:
- upon the kth query, where k varies from object to object, the object is unlocked
- every unlock request increments the smallest value in the sequence
- lock(x) tests x against either the minimum or maximum value of the sequence
- retrieve() returns an paired key
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
