How to use method of org.jmock.example.sniper.Money class

Best Jmock-library code snippet using org.jmock.example.sniper.Money.

Run Jmock-library automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

copy
1package org.jmock.example.sniper;
2
3import java.math.BigDecimal;
4
5public class Money implements Comparable<Money> {
6    private BigDecimal amount;
7
8    public Money(BigDecimal amount) {
9        this.amount = amount;
10    }
11
12    public Money(int amount) {
13        this(new BigDecimal(amount));
14    }
15
16    public Money(double amount) {
17        this(new BigDecimal(amount));
18    }
19
20    public Money add(Money other) {
21        return new Money(amount.add(other.amount));
22    }
23
24    public Money subtract(Money other) {
25        return new Money(amount.subtract(other.amount));
26    }
27
28    @Override
29    public String toString() {
30        return "£" + amount;
31    }
32
33    @Override
34    public boolean equals(Object o) {
35        if (this == o) return true;
36        if (o == null || getClass() != o.getClass()) return false;
37        return amount.equals(((Money) o).amount);
38    }
39
40    @Override
41    public int hashCode() {
42        return amount.hashCode();
43    }
44
45    public int compareTo(Money other) {
46        return amount.compareTo(other.amount);
47    }
48
49    public static Money min(Money m1, Money m2) {
50        return new Money(m1.amount.min(m2.amount));
51    }
52}
53
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Most used method in Money

Trigger code on LambdaTest Cloud Grid

Execute automation tests with on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)