I wrote a code which is for the total price of book when multiplied by number of book and the book price in VDM++.
class Book
types
public Title = seq of char;
instance variables
private bookTitle: Title;
private numberOfPages: nat1;
private totalPrice : real;
private price : real;
private noofBook : nat1;
inv numberOfPages >= 1 and numberOfPages <= 100;
values
public Price: real = 20.50;
operations
expCalculateTotalPrice: nat1 * real ==> real
expCalculateTotalPrice (noofBook,price) ==
(
totalPrice := noofBook * price;
return totalPrice;
)
operations
impCalculateTotalPrice(Book:real) price:real
pre price > noofBook and price > 0
post totalPrice = noofBook * price
end Book
the error is "The state component "totalPrice" must not be used here" which is
post totalPrice = noofBook * price
what is wrong with these?