A postcondition is some condition which must be satisfied after running a given section of code. It may be specified in code via assertions, or in the documentation.
Questions tagged [post-conditions]
58 questions
0
votes
3 answers
The meaning of postcondition
I can understand the meaning and purpose of preconditions in this code but I have a problem in understanding the meaning and purpose of the postconditions. In Push I know that this part to increase pointer after pushing integer ( Pointer = Pointer~…

Memo
- 53
- 6
0
votes
2 answers
Unknown identifiers for ensure block in Eiffel
So I'm new to Eiffel programming and I'm trying to learn to write postconditions in the ensure block of a feature, in particular with writing loops.
So I tried this:
feature
-- sets the value of a particular in an array to x
foo (a:…

M. Fire
- 117
- 2
- 6
0
votes
1 answer
Enterprise Architect Operation Pre/Post-Conditions
i am using EA to model some c-components. i know that EA can't be used efficiently with C language but i am trying to stick to the intended usage of each element as possible as i can.
my question... i am modelling a C-file using a class and…

Mo.Hussein
- 33
- 1
- 8
0
votes
1 answer
Precondition and class containment
Assume I have the following class:
public class Player {
private Board board;
private int roundsPlayed = 0;
public void play() {
while (board.isAvailable() && roundsPlayed < 10) {
// playing on the board
roundsPlayed++;
…

shaqed
- 342
- 3
- 17
0
votes
0 answers
Dafny - Propagate ensures clause?
What I'm having issue with is two different methods in two different classes not cooperating, the set-up is as following:
class A{
method b()
ensures statement
{
// Do something
}
}
class C{
method d()
requires…

David S
- 195
- 5
- 19
0
votes
2 answers
Java - Method Preconditions and postcondition enforcement
My question is short. Are method preconditions and postconditions enforced by the compiler?

JungleJeem
- 51
- 8
0
votes
2 answers
Eiffel exception not work
I'm trying to use an exception like in the class below, but the program always fails when I call the kivetel method. I'd think that it'll just call retry part, than it will satisfy the postcondition. But it fails with "y_above_zero" postcond…

Ferenc Dajka
- 1,052
- 3
- 17
- 45
0
votes
2 answers
Java data encapsulation, initializing and postconditions?
My assignment is to complete the Date class shown below. The Date class encapsulates a date by storing the month, day, and year in private instance variables.
public class Date
{
// declare your instance variables here
// postcondition:…

Renea S.
- 91
- 1
- 11
0
votes
1 answer
The max searching algorithm
Dear Experts and enthusiasts,
I would like to solve the following problem:
I have an array of natural numbers. I would like to find their maximum.
But I have to show my solution with structogram, like that
…

Váczi Attila
- 7
- 2
0
votes
1 answer
Greatest Common Divisor - Pre and Postconditions
The following provides a pre and post condition for the gcd method.
pre: x > 0 & y > 0
post: result > 0 &
x mod result = 0 & y mod result = 0 &
∀t:Integer · t > 0 & x mod t = 0 & y mod t = 0 ⇒ result mod t = 0
However, I'm having…

mark
- 2,841
- 4
- 25
- 23
-1
votes
1 answer
Find inputs to a function which break the postcondition on the output
I have a function in a programming language, e.g. C. I require the output of the function to meet a certain condition. If there is some input to this function for which the output does not meet the required condition, I need to find any such exact…

Dávid Natingga
- 839
- 3
- 13
- 30
-1
votes
1 answer
Dafny - Assertion violation after calling class method from Main
I'm writing up some simple code for a class which intializes baseball runs to 0. Its only method is supposed to take in the number of runs as its parameter, and return a bool based on whether the input was larger than the class variable and an int,…

Dafneloper
- 19
- 2
-3
votes
1 answer
Precondition and postcondition in Java
Question that makes me think:
when we speak of precondition in a method we refer to a condition verified by the method itself(1) or to a condition verified by the caller(2)?
for example
(1)
...
withdrawal(100);
}
void withdrawal(int v)
{
…

pasquale annarumma
- 11
- 1