CappedChecking – represents a checking account that disallows a balance above a particular maximum value.
Class CappedChecking - deposit - deposits a given amount into the account as described previously link - given an account acct, link this account with acct
account will be labeled as Filterable.That is,you must appropriately define an abstract class or interface representing the filterable notion. Each such filterable class must implement the method boolean accept() which returns true or false based on the following criteria: The minimum amount for a checking account is $0. There is no maximum for a standard checking account, while capped checking accounts have maximum $10000.
________________________________________________________________________________________
public class CappedChecking // TODO: refine this to establish
proper relationships among accounts.
{
//
// TODO: Constructors and other required methods.
//
@Override
public boolean equals(Object obj)
{
if (obj == null) return false;
if (!(obj instanceof CappedChecking)) return
false;
return super.equals(obj);
}
@Override
public String toString()
{
return "Capped-Checking " + super.toString();
}
}
//source code//
package HomeworkLib;
interface Filterable
{
public boolean accept(double money);
}
class CappedChecking implements Filterable// TODO: refine this to establish proper relationships among accounts.
{
//
// TODO: Constructors and other required methods.
//
private String acc_no;
private String name;
private double balance;
public CappedChecking(String acNo, String nm, double bal) {
// TODO Auto-generated constructor stub
acc_no = acNo;
name = nm;
balance = bal;
}
@Override
public boolean equals(Object obj) //assuming these methods are coorectly implemented so not touching these methods
{
if (obj == null) return false;
if (!(obj instanceof CappedChecking)) return false;
return super.equals(obj);
}
@Override
public String toString()
{
return "Capped-Checking " + super.toString();
}
public String displayDetails() // implement method to display details of a account
{
return "Name : " + this.name + "\nAccount Number : " + this.acc_no + "\nBalance : " + this.balance + "\n";
}
@Override
public boolean accept(double money) { //implement the accept method in this Filterable class
// TODO Auto-generated method stub
if(money<0 || money > 10000)
return false;
else
return true;
}
public String getAcc_no() {
return acc_no;
}
public void setAcc_no(String acc_no) {
this.acc_no = acc_no;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
public void deposit(double money) //deposit method to deposit money
{
if(this.accept(this.balance+money)) //if this much money after depoist is accepted in the account make the deposit
{
this.balance += money;
System.out.println("Deposit has been successfully completed ");
}
else //else give message that deposit can't be done
System.out.println("You can not deposit this amount as it is exceeding your total max capping");
}
public double withdraw(double money)
{
if(this.accept(this.balance-money)) //if this much money after depoist is accepted in the account make the deposit
{
this.balance -= money;
System.out.println("WithDraw has been successfully completed");
return money;
}
else{
System.out.println("Withdraw failed as it is making balance below capped amount");
return -1;
}
}
}
public class CappedCheckingTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
CappedChecking cca1 = new CappedChecking("12345", "John", 6000); //creating account
CappedChecking cca2 = new CappedChecking("23456", "Peter", 3000);
System.out.println(cca1.displayDetails());
System.out.println(cca2.displayDetails());
cca1.deposit(3000); //checking for deposit and withdraw method
System.out.println(cca1.displayDetails());
cca1.deposit(2000);
System.out.println(cca1.displayDetails());
cca2.withdraw(2500);
System.out.println(cca2.displayDetails());
cca2.withdraw(900);
System.out.println(cca2.displayDetails());
}
}
//sapmle ouput//
Name : John
Account Number : 12345
Balance : 6000.0
Name : Peter
Account Number : 23456
Balance : 3000.0
Deposit has been successfully completed
Name : John
Account Number : 12345
Balance : 9000.0
You can not deposit this amount as it is exceeding your total
max capping
Name : John
Account Number : 12345
Balance : 9000.0
WithDraw has been successfully completed
Name : Peter
Account Number : 23456
Balance : 500.0
Withdraw failed as it is making balance below capped
amount
Name : Peter
Account Number : 23456
Balance : 500.0
CappedChecking – represents a checking account that disallows a balance above a particular maximum value. Class...
Templates Apartment.java package hwk7; public class Apartment { int numOfApartments; // the number of apartments of this type Room[] rooms; // rooms in this type of apartment Apartment(int numOfApartments, Room[] rooms) { this.numOfApartments = numOfApartments; this.rooms = rooms; } // Return the window orders for one apartment of this type as TotalOrder object TotalOrder orderForOneUnit() { // TODO } // Return the window...
This is my code that i need to finish. In BoxRegion.java I have no idea how to create the constructor. I tried to use super(x,y) but It is hard to apply. And Also In BoxRegionHashTable, I don't know how to create displayAnnotation BoxRegion.java ------------------------------------------------ public final class BoxRegion { final Point2D p1; final Point2D p2; /** * Create a new 3D point with given x, y and z values * * @param x1, y1 are the x,y coordinates for point...
The current code I have is the following: package uml; public class uml { public static void main(String[] args) { // TODO Auto-generated method stub } } class Account { private String accountID; public Account(String accountID) { this.accountID = accountID; } public String getAccountID() { return accountID; } public void setAccountID(String accountID) { this.accountID = accountID; } @Override public String toString() { return "Account [accountID=" + accountID + "]"; } } class SuppliesAccount extends Account { private...
Writing 3 Java Classes for Student registration /** * A class which maintains basic information about an academic course. */ public class Course { /** * Attributes. */ private String code; private String title; private String dept; // name of department offering the course private int credits; /** * Constructor. */ public Course(String code, String title, int credits) { // TODO : initialize instance variables, use the static method defined in // Registrar to initialize the dept name variable...
ATM Revisited In Java, design a subclass of the Account class called GoldAccount. It is still an Account class, however it has an additional field and some additional functionality. But it will still retain all the behavior of the Account class. Write a class called GoldAccount. This class will have an additional private field called bonusPoints. This field will require no get or set methods. But it will need to be initialized to 100 in the constructor. Thereafter, after a...
In Pl you will create an interface, Drawable, and an abstract class Polygon. The Point class is provided. Briefly go over the JavaDocs comments to see what is available to you. «interface Drawable +printToConsole(): void Polygon - points : List<Point> - colour : String Point + Polygon(String colour) + getPoints(): List<Point> + addPoint(Point p): void + equals(Object other): boolean +getArea(): double • The Polygon constructor initializes the List to a List collection of your choosing • add Point: Adds a...
Copy the program AmusementRide.java to your computer and add your own class that extends class AmusementRide. Note: AmusementRide.java contains two classes (class FerrisWheel and class RollerCoaster) that provide examples for the class you must create. Your class must include the following. Implementations for all of the abstract methods defined in abstract class AmusementRide. At least one static class variable and at least one instance variable that are not defined in abstract class AmusementRide. Override the inherited repair() method following the...
Please help me do the java project For this project you will be reading in a text file and evaluating it in order to create a new file that represents the Class that will represent the properties of the text file. For example, consider the following text file: students.txt ID Name Age IsMale GPA 1 Tom Ryan 22 True 3.1 2 Jack Peterson 31 True 2.7 3 Cindy LuWho 12 False 3.9 When you read in the header line, you...
departmentstore: package departmentstorepkg; import java.util.ArrayList; public class DepartmentStore { private static final int DEFAULT_SIZE = 10; private StaffMember [] myEmployees; private int myNumberEmployees; private String myFileName; private StaffMember[] employee; public DepartmentStore (String filename){ myFileName = filename; myEmployees = employee; } public String toString(){ return this.getClass().toString() + ": " + myFileName; } public void addEmployee(Employee emp){ } /** * prints out all the employees in the array list held in this class */ public void print(){ for(int i =...
Susceptible.java interface Susceptible { public boolean infect(Disease disease); public void forceInfection(Disease disease); public Disease getCurrentDisease(); public void setImmune(); public boolean isImmune(); public Point getPosition(); } Movable.java interface Movable { public void move(int step); } public class Point { private int xCoordinate; private int yCoordinate; /** * Creates a point at the origin (0,0) and colour set to black */ public Point(){ xCoordinate = 0; yCoordinate = 0; } /** * Creates a new point at a given coordinate and colour...