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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started