TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
RAHUL goswami
NA
10
8.7k
domain matrix for testing
Oct 10 2013 11:27 AM
How we can design the domain matrix for testing the withdraw method using the domain testing technique. please help if anyone know!
here is the example:
public class BankAccount{
private double balance;
private boolean closed;
public BankAccount(){
balance = 0;
closed = false;
}
public double getBalance(){
return balance;
}
// deposit requires the following condition
// amount>=0 && !isClosed()
public void deposit(double amount) {
if (closed) {
System.out.println("Cannot deposit because the account is closed!");
return; // throwing an exception would be better
}
if (amount>=0) {
balance = balance + amount;
}
}
// withdraw requires the following condition
// getBalance()>0 && amount>0 && getBalance() - amount>=0 && !isClosed()
public void withdraw(double amount) {
// error!
//
if (closed) {
//
System.out.println("Cannot withdraw because the account is closed!");
//
return; // throwing an exception would be better
//
}
if (balance>0 && amount>0 && balance-amount>=0) {
balance = balance - amount;
}
}
public void close() {
if (balance>=0) {
withdraw (balance);
closed = true;
}
}
public boolean isClosed() {
return closed;
}
}
Reply
Answers (
0
)
mac mail file transfer to windows outlook
Dell Laptop Not Recogning Wifi Connections