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.

  1. lock(x) -- returns a bool
    1. if locked, freezes object
    2. else if x>mean value of encapsulated sequence, locks object
  2. unlock(y) -- returns a bool unlocks the object if y appears in the encapsulated sequence
  3. 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:

  1. when the number of failed unlock requests exceeds a bound, the object is frozen
  2. a failed (but not frozen) lock(y) request adds y to the sequence
  3. retrieve() returns an inverted key

lockSecret object is-a lock and thus operates like an lock object, except that:

  1. upon the kth query, where k varies from object to object, the object is unlocked
  2. every unlock request increments the smallest value in the sequence
  3. lock(x) tests x against either the minimum or maximum value of the sequence
  4. retrieve() returns an paired key

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!