So in class over the past few days we have been doing constructors, which are kinda neat once you learn how do work with them. I have attached my 5th assignment to this entry to it may help someone out one day (including myself as a good reference)
I have to say my old "Learn Java now" book from Stephen R. Davis (Microsoft Press) that I got with my copy of J++ I bought years ago (1.0) has turned out to be quite helpful, more helpful than my "Learn Java in 21 days" book and the in class book "Big Java"
class Bank
{
public static void main(String[] args)
{
SavingsAccount mySavings = new SavingsAccount(100.0,"John Smith");
System.out.println ("The current account Balance is? "+ mySavings.Balance());
}
}
class SavingsAccount extends BankAccount
{
SavingsAccount(double initBalance, String initName)
{
super("savings", initName, initBalance);
}
}
public class BankAccount
{
protected String accountType;
protected String accountName;
protected double Balance;
BankAccount ()
{
}
BankAccount (String typeDef, String nameDef)
{
accountType=typeDef;
accountName=nameDef;
}
BankAccount (String typeDef, String nameDef, double initBalance)
{
this(typeDef, nameDef);
Balance=initBalance;
}
public void Deposit(double Amount)
{
if (Amount > 0.0)
Balance += Amount;
}
public void Withdrawl(double Amount)
{
if (Amount >= 0.0)
{
if (Amount <= Balance)
Balance -= Amount;
}
}
public double Balance()
{
int nCents = (int)(Balance * 100 + 0.5);
return nCents / 100.0;
}
}