Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design and implement a class called Flight that represents an airline flight. It

ID: 665239 • Letter: D

Question

Design and implement a class called Flight that represents an airline flight. It should contain data that represents an airline name, flight number, and the flight’s origin and destination cities. Define the Flight constructor to accept and initialize all data. Include getter and setter methods for all data. Include a toString method that returns a one-line description of the flight.

Now create a class called FlightTest .This class will be instantiates the Flight objects. In it the user should be able to add fight information about an airline to the instance variables of Fight. You need to have two instances of Fight in this class. The user should also be able to display the flight information for both flights.

Design and implement a class called BankAccount that represents a Bank Account. It should contain the customer account number and balance. Define the BankAcount constructor to accept and initialize all data. Include getter and setter methods for all instance data. Include a toString method that returns a one-line description of the a bank Account

Create a Portfolio class that has two objects, checking and savings, of the type BackAccount that was developed above. Add four methods to this class:

The first is to make a deposit to the correct account. The amount of the deposit, the type of the account, “s” for savings or “c” for checking.

The second method is to make withdraws from an account using the same fields that the deposit use above.

The third method is to allow the user to transfer an amount between the two accounts. The user needs to indicate the account the money is being transferred from in this case.

The fourth method should allow the user to see the balance of the account.

Explanation / Answer

Flight.java

package demo1;


/**
*
*
* Design and implement a class called Flight that represents an airline flight.
* It should contain data that represents an airline name, flight number, and the flight’s origin and destination cities.
* Define the Flight constructor to accept and initialize all data. Include getter and setter methods for all data.
* Include a toString method that returns a one-line description of the flight.
*
*/


public class Flight {
   String airlinename;
   String flightnumber;
   String flightorigin;
   String destination;
  
  
   public Flight(String airlinename, String flightnumber, String flightorigin,
           String destination) {
       super();
       this.airlinename = airlinename;
       this.flightnumber = flightnumber;
       this.flightorigin = flightorigin;
       this.destination = destination;
   }


   public String getAirlinename() {
       return airlinename;
   }


   public void setAirlinename(String airlinename) {
       this.airlinename = airlinename;
   }


   public String getFlightnumber() {
       return flightnumber;
   }


   public void setFlightnumber(String flightnumber) {
       this.flightnumber = flightnumber;
   }


   public String getFlightorigin() {
       return flightorigin;
   }


   public void setFlightorigin(String flightorigin) {
       this.flightorigin = flightorigin;
   }


   public String getDestination() {
       return destination;
   }


   public void setDestination(String destination) {
       this.destination = destination;
   }
  
  

}

FlightTest.java

package demo1;

public class FlightTest {

   /**
   * @param args
   * Now create a class called FlightTest .This class will be instantiates the Flight objects.
   * In it the user should be able to add fight information about an airline to the instance variables of Fight.
   * You need to have two instances of Fight in this class.
   * The user should also be able to display the flight information for both flights
   *
   *
   */
   public static void main(String[] args) {
       Flight airasia=new Flight("AIRASIA","12345","Dellas","Newyork");
      
       Flight flanksport=new Flight("FLANKSPORT","67895","russia","usa");
      
      
       System.out.println("Flight information: "+airasia.getAirlinename());
       System.out.println("Flight No:"+airasia.getFlightnumber());
       System.out.println("Flight origin:"+airasia.getFlightorigin());
       System.out.println("Flight Destination:"+airasia.getDestination());
      
      
       System.out.println("Flight information: "+flanksport.getAirlinename());
       System.out.println("Flight No:"+flanksport.getFlightnumber());
       System.out.println("Flight origin:"+flanksport.getFlightorigin());
       System.out.println("Flight Destination:"+flanksport.getDestination());

   }

}

BankAccount.java

package demo1;

public class BankAccount {

   /**
   * @param args
   *
   * Design and implement a class called BankAccount that represents a Bank Account.
   * It should contain the customer account number and balance. Define the BankAcount constructor to accept and initialize all data.
   * Include getter and setter methods for all instance data. Include a toString method that returns a
   * one-line description of the a bank Account
   */
  
private int accountnumber;
private float balance;
public BankAccount(int accountnumber, float balance) {
   super();
   this.accountnumber = accountnumber;
   this.balance = balance;
}
public int getAccountnumber() {
   return accountnumber;
}
public void setAccountnumber(int accountnumber) {
   this.accountnumber = accountnumber;
}
public float getBalance() {
   return balance;
}
public void setBalance(float balance) {
   this.balance = balance;
}
@Override
public String toString() {
   return "BankAccount [accountnumber=" + accountnumber + ", balance="
           + balance + ", getAccountnumber()=" + getAccountnumber()
           + ", getBalance()=" + getBalance() + ", getClass()=" + getClass()
           + ", hashCode()=" + hashCode() + ", toString()=" + super.toString()
           + "]";
}


}

PortFolio.java

package demo1;

public class PortFolio {

   /**
   * @param args
   *
   * Create a Portfolio class that has two objects, checking and savings,
   * of the type BackAccount that was developed above. Add four methods to this class:

The first is to make a deposit to the correct account.
The amount of the deposit, the type of the account, “s” for savings or “c” for checking.
The second method is to make withdraws from an account using the same fields that the deposit use above.
The third method is to allow the user to transfer an amount between the two accounts. The user needs to indicate the account the money is being transferred from in this case.
The fourth method should allow the user to see the balance of the account
   */
  
   public void depositAmount(BankAccount choice,float amount)
   {
       float b=choice.getBalance();
       choice.setBalance(b+amount);
   }
   public void withdrawAmount(BankAccount choice,float amount)
   {
       float b=choice.getBalance();
       if(b>amount)
       choice.setBalance(b-amount);
   }
  
   public String transferFunds(BankAccount cr,BankAccount de,float amount)
   {
       float d=de.getBalance();
       float c=cr.getBalance();
       String state="fail";
       System.out.println(d);
       if(d>amount)
       {
           de.setBalance(d-amount);
           cr.setBalance(c+amount);
           state="success";
       }
       else
       {
           state="fail";
       }
      
       return state;
   }
  
  
   public float getBalance(BankAccount c)
   {
       return c.getBalance();
   }
   public static void main(String[] args) {
  
   PortFolio portFolio=new PortFolio();  
      
      BankAccount checking=new BankAccount(123456, 2000);
      BankAccount savings=new BankAccount(789123, 4000);
      System.out.println("Before Depositing......in checking"+checking.getBalance());
       portFolio.depositAmount(checking, 500);
       System.out.println("After Depositing......in checking"+checking.getBalance());
    
       System.out.println("Before Depositing......in savings"+savings.getBalance());
       portFolio.depositAmount(savings, 1500);
       System.out.println("After Depositing......in savings"+savings.getBalance());
    
     
       System.out.println("Before Withdrawing......in savings"+savings.getBalance());
       portFolio.withdrawAmount(savings, 1500);
       System.out.println("After Withdrawing......in savings"+savings.getBalance());
     
       System.out.println("Before transfer credior balance:: "+portFolio.getBalance(checking));
       System.out.println("Before transfer debitor balance:: "+portFolio.getBalance(savings));

       String state=portFolio.transferFunds(checking, savings,1000);
       if("success".equalsIgnoreCase(state))
       {
           System.out.println("Money Transfer Success.........");
       System.out.println("After transfer credior balance:: "+portFolio.getBalance(checking));
       System.out.println("After transfer debitor balance:: "+portFolio.getBalance(savings));
       }
       else
       {
           System.out.println("Insifficient money.........");
           System.out.println("After transfer credior balance:: "+portFolio.getBalance(checking));
           System.out.println("After transfer debitor balance:: "+portFolio.getBalance(savings));
           }
   }
  
  

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote