Week 8 Java Project [Ticket.java]

 /**

 * ITEC 8030 Week 8 Project
 * @author AMARE
 */
import java.text.SimpleDateFormat;
import java.util.Date;
public class Ticket 
{
  SimpleDateFormat d = new SimpleDateFormat("dd/MM/yyyy");
    private long number;
    private String category = new String();
    private String holder = new String();
    private Date date = new Date();
    private double price;
    private boolean purchaseStatus;
    
    /**
     * The parameterized constructor method accepts arguments
     * @param number
     * @param category
     * @param holder
     * @param date
     * @param price
     * @param purchaseStatus 
     */
    
    public Ticket(long numberString categoryString holderDate datedouble priceboolean purchaseStatus) {
        this.number = number;
        
        if (category.equalsIgnoreCase("adult")) {
            this.category = category;
        } else if(category.equalsIgnoreCase("child")) {
            this.category = category;
        } else if(category.equalsIgnoreCase("senior")){
            this.category = category;
        }else{
            System.out.println("Invalid ticket category. Please, talk to a member of staff.");
        }
        
        this.holder = holder;
        this.date = date;
        this.price = price;
        this.purchaseStatus = purchaseStatus;
    }
    
    /**
     * No argument constructor method applies
     */
    public Ticket() {
    }

    /**
         * The parameterized constructor method accepts arguments
         * @param price 
         */
    public void setPrice(double price) {
        this.price = price;
    }
    
    /**
         * The parameterized constructor method accepts 
         * @param newValue 
         */
    public void changePurchaseStatus(boolean newValue){
        this.purchaseStatus = newValue;
    }
    
    /**
         * boolean method 
         * @return 
         */
    public boolean getPurchaseStatus()
        {
        boolean status;
        if (this.purchaseStatus == true)
                {
            status = true;
        } 
                else 
                {
            status = false
        }
        return status;
    }

    /**
         * The no arguments constructors method returns number
         * @return 
         */
    public long getNumber()
        {
        return number;
    }
    
    /**
         * The no arguments constructors method returns category
         * @return 
         */
    public String getCategory() 
        {
        return category;
    }
    
    /**
         * The no arguments constructors method returns holder
         * @return 
         */
    public String getHolder()
        {
        return holder;
    }
    
    /**
         * The no arguments constructors method returns date
         * @return 
         */
    public Date getDate() 
        {
        return date;
    }
    
    /**
         * The no arguments constructors method returns price
         * @return 
         */
    public double getPrice() 
        {
        return price;
    }

    /**
         * The no arguments constructors method returns Strings
         * @return 
         */
    public String toString()
        {
        return "Ticket purchased: " + getPurchaseStatus() + "\nThe Ticket number is " + getNumber() + ", the category is. \n" + getCategory() + "This ticket belongs to " + getHolder() + 
                ", admits one person on " + getDate() + " and costs $" + getPrice();
    }
}

Comments

Popular posts from this blog

Nаturаl Resource Conservаtion аnd Environmentаl Protection of the Nile River

Assignment 3: Apple versus Samsung

Week 8 Java Project [AmusementPark.java]