Question: OOP EXAMPLE Q1 : Q2 : Q3 : public boolean equals(Object other) { Question 1 (Class Design): Complete the Bank Account class below: // Check
OOP EXAMPLE
Q1 :
Q2 :
Q3 :

public boolean equals(Object other) { Question 1 (Class Design): Complete the Bank Account class below: // Check that input argument is NOT ZERO or NEGATIVE public void setAcc_num( ) { } } public class Bank Account { private int acc_num; private String acc_holder; private double balance; } public String getAcc_holder() { return(this.acc_holder); } // Full-Argument Construcor // Check that input acc_id argument is NOT ZERO or NEGATIVE // Check that input acc_holder argument is NOT NULL // Check that input balance argument is NOT NEGATIVE public Bank Account ) { public void setAcc_holder(String acc_holder) { if(acc_holder null) throw new NullPointerException("No name for account holder!"); this.acc_holder = acc_holder; } public int geBalance() { } } // No-Argument Construcor : MUST CALL Full-Argument Constructor public Bank Account() { // Check that inpuut argument is NOT NEGATIVE public void setBalance ) { } } // Copy Construcor : MUST CALL Full-Argument Constructor // MUST CHECK THAT other is not NULL! public Bank Account(Bank Account other) { // MUST return Bank Account(ID = acc_numb, Name = acc_holder has balance Saudi Riyals) @Override public String toString() { } } public int ge Acc_num() { // Note: 2 Bank Account are equal if they have the same account number and different otherwise. @Override } Question 2 (Inheritance): } You are given classes called Person, Student, Faculty, Employee and Man- ager. public class Manager { Assume that the class Person is defined as follows: public Boolean get Status() { public class Person { } } public String getName() { } 2.1 Complete the main() method below to create an array of 200 objects of different types (Person, Student, Faculty, Employee and Manager) in a random fashion. } 1. Complete the class definitions below: public static void main(String[] args) { public class Student { public int getId() { } } } 2.2 Make sure to call the following methods in the main() method: public class Faculty { public String getName() public String getRank() { public int getId() } public String getRank() } public double get Salary() public class Employee { public Boolean getStatus() public double getSalary() { public static void main(String[] args) { } 1. Define an abstract class called Savable: public abstract class Savable { // ONE variable called : SAVING_RATE of type double and set to 0.2 // One abstract method called apply_savings() that takes the number of years as input argument and returns the applied savings rate. } 2.1 Let the class Bank Account extend the Savable class. Complete the class definition below: public class Bank Account { 2.2 The BankAccount class will override the apply_savings() inherited from the Savable class where it will return the product between the Bank Account balance field and the input argument defining the number of years. Complete the code below: // DO all necessary checks (input argument cannot be negative!)! @Override apply_savings ) { }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
