Question: A) Describe what this class represents and what it does: B) What methods make up the classs public interface? public class MyClass { private String
|
public class MyClass
{
private String firstName;
private String lastName;
private int idNumber;
private double balance;
public MyClass()
{
this.firstName = "";
this.lastName = "";
this.idNumber = -1;
this.balance = 0.0;
}
public MyClass(String firstName, String lastName, int id)
{
this.firstName = firstName;
this.lastName = lastName;
this.idNumber = id;
this.balance = 0.0;
}
public void makeDeposit(int id, double amount)
{
if(this.confirm(id))
{
this.balance += amount;
}
}
public void withdraw(int id, double amount)
{
if(this.confirm(id))
{
if(amount > this.balance)
System.out.println("Not enough in account");
else
this.balance -= amount;
}
}
private boolean confirm(int id)
{
if(this.idNumber == id)
return true;
else
{
System.out.println("INVALID");
return false;
}
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
