Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
BankAccount
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
/** A bank account has a balance that can be changed by deposits and withdrawals. */ public class BankAccount : IComparable { //Overrides the toString method in Object class public string ToString() { return GetType().FullName + "[balance= " + balance + "]"; } //Implements the compareTo method in the Comparable interface public int CompareTo (object anObject) { BankAccount anAccount = (BankAccount) anObject; if (Math.abs(balance - anAccount.getBalance()) <= EPSILON) return 0; if (balance < anAccount.getBalance()) return -1; return 1; } /** Constructs a bank account with a zero balance. */ public BankAccount() { balance = 0; } /** Constructs a bank account with a given balance. */ public BankAccount(double initialBalance) { balance = initialBalance; } /** Deposits money into the bank account. */ public void deposit(double amount) { balance = balance + amount; } /** Withdraws money from the bank account. */ public void withdraw(double amount) { balance = balance - amount; } public double getBalance() { return balance; } private double balance; final double EPSILON = 1E-14; }
Show compiler warnings
[
+
]
Show input
Compilation time: 0,03 s
edit mode
|
history
|
discussion
Error(s):
(60:10) Invalid token 'double' in class, struct, or interface member declaration