Untitled

mail@pastecode.io avatar
unknown
java
3 years ago
1.1 kB
2
Indexable
Never
// Online Java Compiler
// Use this editor to write, compile and run your Java code online

class HelloWorld {
    public static void main(String[] args) {
        Account account = new SalaryAccount("Accenture"); 
    account.createAccount(); 
    System.out.println("Balance : " + account.getMinimumBalance());
    account.checkCompany();
    System.out.println("Balance : " + account.getMinimumBalance());
    }
}

// -----------------------------------------------------------


class Account 
 { 
       int balance; 
       public void createAccount() 
       { 
         balance = 1000; 
       } 
       public int getMinimumBalance() 
       { 
         return balance;
       } 
 } 
class SalaryAccount extends Account 
{ 
    private String companyName;
    public SalaryAccount(String companyName) 
    { 
        this.companyName = companyName; 
    }
    public void createAccount() 
    { 
        balance = 500; 
    } 
    public void checkCompany() 
    {
        if (companyName.equalsIgnoreCase("Accenture")) 
        { 
            balance = 0;
        } 
    } 
}