In: Computer Science
I want answers of the following questions
My lab assingment:
its a program written in netbean ide 8.2
My topic: Bank Account
Program code:
class Account{
int acc_no;
String name;
float amount;
void insert(int a,String n,float amt){
acc_no=a;
name=n;
amount=amt;
}
void deposit(float amt){
amount=amount+amt;
System.out.println(amt+" deposited");
}
void withdraw(float amt){
if(amount<amt){
System.out.println("Insufficient Balance");
}else{
amount=amount-amt;
System.out.println(amt+" withdrawn");
}
}
void checkBalance(){System.out.println("Balance is:
"+amount);}
void display(){System.out.println(acc_no+" "+name+"
"+amount);}
}
class TestAccount{
public static void main(String[] args){
Account a1=new Account();
a1.insert(832345,"Ali",1000);
a1.display();
a1.checkBalance();
a1.deposit(40000);
a1.checkBalance();
a1.withdraw(15000);
a1.checkBalance();
}}
Task: Each one of you was given a Lab assignment of choosing a real
world object to be represented as a programming object and writing
a class code for that object. You have been asked to mimic at least
3 states and 3 behaviors of that object.
Your theory assignment is to provide the detail analysis on your
part while you selected and mimic that object in programing
language. You are to provide brief insight and analysis you have
done in each the following:
1. What was your inspiration to choose that object?
2. Which 3 states you choose and why?
3. Do all the behaviors correspond directly to your states or not?
4. What were the challenges you faced with selecting the object?
5. If you were to asked to choose another object, which object
will you choose and why?
1. What was your inspiration to choose that object?
The banking system is fully operated and maintained digitally. There is a program that acts as an interface to provide an easy, flexible, abstracted and highly secure way to maintain the banking system.
2. Which 3 states you choose and why?
The states of the bank account are:
3. Do all the behaviors correspond directly to your states or not?
4. What were the challenges you faced with selecting the object?
Choosing a real life common object with appropriate states and behaviours.
5. If you were to asked to choose another object, which object will you choose and why?
A dog object with states as his name, his color and his breed, and behaviour like barking, eating and sleeping.