1. Engineering
  2. Computer Science
  3. this program exercises your understanding of containment composition and class...

Question: this program exercises your understanding of containment composition and class...

Question details

This program exercises your understanding of containment, composition and class maintenance

Additionally, you MUST use Programming By Contract.

The goal is to design and implement the C# classes needed to implement comparative data sets, as described below.

A. Design an encapsulated closePrime class. Each closePrime object encapsulates a ‘hidden’ digit and, if active, returns the prime number that is ‘hidden’ steps away from a query. For example, an ‘active’ closePrime object encapsulating the digit ‘3’ would return 97 upon a ping passing in 75 (as the closest prime that is 3 primes away from 75: 79, 83, and 89 being the ‘3’ intermediary primes). Every closePrime object is initially active but transitions to inactive if the count of received values exceeds some multiple (other than 1) of its hidden digit. The client programmer may query, reset, and/or revive a closePrime object in addition to pinging values. An attempt to revive an active closePrime object causes that object to be permanently deactivated.

B. Design and implement two classes, each of which encapsulate distinct closePrime objects.

- The first type, trigger, uses 2 closePrime objects to identify all pinged values that yield “stepped prime”s with the same last digit. For example, if a trigger object encapsulated closePrime objects with hidden digits 2 and 5 then a pinged value of 81 would satisfy this criterion (2 steps away: 83, 89 => 97; 5 steps away: 83, 89, 97, 101, 103 => 107) while a pinged value of 78 would not. Cumulative statistics may also be released.

- The second type, multiQ, tracks some number of closePrime objects at a given time and

  1. returns the maximum and minimum ‘stepped prime’ resulting from a query across all encapsulated closePrimes.
  2. Supports cumulative statistics
  3. Adds/Removes closePrime objects
Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution