Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Following the discussion from the lessons, which of the foilowing are valid examples of class invariants? Select one or more: a) In the array-based stack

Following the discussion from the lessons, which of the foilowing are valid examples of class invariants? Select one or more:

a) In the array-based stack implementation, if the stack is not empty, the topmost item should be at position stack_size 1 in the values array, and all the values before that are below it on the stack

b) In the array-based queue implementation, the user should not call push when the queue is empty

c) In the rational number class, the denominator should be greater than 0, and the numerator and denominator should not have a GCD greater than 1

d) in a clock class, the hours field should be between 0 and 23 (inclusive), and the minutes and seconds between 0 and 59 (inclusive)

e) In the rational number class, the user should not try to construct a rational with a denominator of 0

f) In the car class, the user should not call the turn_off function when the speed is greater than 0

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

Pro SQL Server Wait Statistics

Authors: Enrico Van De Laar

1st Edition

1484211391, 9781484211397

More Books

Students also viewed these Databases questions