All pastes #277213 Raw Edit

Stuff

public text v1 · immutable
·published 2006-12-13 00:34 UTC
rendered paste body
package LawnService;

public class Client
{
//**Setters and getters for variables**
//Client info:
//Client Name, Lawn Size (Width Length), Number of payments, Amount of Payment, Total of all Payments
//Summary Report info:
//TotNumClients, TotSqFtOfMowing, RevenueForSummer
    private String CName;
    private int Length;
    private int Width;
    private int NumPay;
    private int AmtPay;
    private int TotPay;
    private int SeCharge;
    private int SerCharge;
    
    public int getLength()
    {
        return Length;
    }
    
    
    public void setLength(int Length)
    {
        this.Length = Length;
    }
    
    
    public int getWidth()
    {
        return Width;
    }
    
    
    public void setWidth(int Width)
    {
        this.Width = Width;
    }

    public String getCName()
    {
        return CName;
    }
    
    public void setCName(String CName)
    {
        this.CName = CName;
    }
   
    public int getNumPay()
    {
        return NumPay;
    }
    
    public void setNumPay(int NumPay)
    {
        this.NumPay = NumPay;
    }
    
    //**Charge Calculation**
    public int SeasCharge()
    {
    //Season charge (based on size of lawn)
    //if size > 400sqft then charge =25/week * numofweeks
    //if size <=400sqft & >600 then charge =35/week * numofweeks
    //if size <=600sqft then charge =50/week * numofweeks
    //return season charge
    
        if (Length * Width < 400)
        {
            SeCharge = 25 * 20;
        }
        else if (Length * Width < 600)
        {
            SeCharge = 35 * 20;
        }
        else
        {
            SeCharge = 50 * 20;
        }
        return SeCharge;
    }
    
    public int ServCharge()
    {
    //Service charge (based on # of payments)
    //if payments =1 then no service charge
    //if payments =2 then 5$/ payment
    //if payments =20 then 3$/payment
    //return service charge
        if (NumPay == 1)
        {
            SerCharge = 0;
        }
        else if(NumPay == 2)
        {
            SerCharge = 10;
        }
        else
        {
            SerCharge = 60;
        }
        return SerCharge;
    }
    public int calculateTotal()
    {
        TotPay = SeasCharge() + ServCharge();
        AmtPay = TotPay / NumPay;
        return TotPay;
    }
    public void display()
    {
    //print output, just like student.java
    //System.out.println();
            calculateTotal();
            System.out.println("Client Name: " + CName);
            System.out.println("Lawn Size: " + Length * Width);
            System.out.println("Total number of payments: " + NumPay);
            System.out.println("Amount of each payment: " + AmtPay);
            System.out.println("Total of all payments: " + TotPay);
    }
}
===============================================================================================
package LawnService;
import java.util.*;
public class ClientProcessor
{
    //Declare HashMap, private Map variablename;
    //Declare ArrayList, private List variablename;
    //Declare array of Clients, private Client[3] variablename;
    //Create variables for client info
    private Map ClientHashMap;
    private List ClientList;
    private Client[] ClientArray;
    private Client CI1;
    private Client CI2;
    private Client CI3;
    
    public void createClients()
    {
        //instantiate HashMap, ArrayList  - new HashMap()  -  new ArrayList()
        //Create the client objects by using the variables previously created
        //e.g. New and . operators
        //also set the values of each Client attribute(variables created in Client)
        // add each client to HashMap, .put(key)=value  -  key is the name of client, value is the client object
        // add each client to ArrayList, .add(value)  -  value is the client object
        // add each client to array of Clients, [number] = value  -  value is the client object, number is a number (1, 2, 3, etc...)
        
        CI1 = new Client();
        CI1.setCName("Bobby Joe");
        CI1.setLength(100);
        CI1.setWidth(100);
        CI1.setNumPay(2);
        CI2 = new Client();
        CI2.setCName("Frankie Figgs");
        CI2.setLength(10);
        CI2.setWidth(2);
        CI2.setNumPay(1);
        CI3 = new Client();
        CI3.setCName("Somethin Somthin");
        CI3.setLength(300);
        CI3.setWidth(10);
        CI3.setNumPay(20);
        
        ClientHashMap = new HashMap();
        ClientHashMap.put("Bobby Joe",CI1);
        ClientHashMap.put("Frankie Figgs",CI2);
        ClientHashMap.put("Somethin Somthin",CI3);
        
        ClientList = new ArrayList();
        ClientList.add(CI1);
        ClientList.add(CI2);
        ClientList.add(CI3);
        
        ClientArray = new Client[3];
        ClientArray[1] = CI1;
        ClientArray[2] = CI2;
        ClientArray[3] = CI3;
    
    }

    public void DisplayClients()
    {
        //Display Client info
        //Client temp;
        //temp = (Client) ClientHashMap.get("Bobby Joe");
        //temp.display();
        //temp = (Client) ClientHashMap.get("Frankie Figgs");
        //temp.display();
        //temp = (Client) ClientHashMap.get("Somethin Somthin");
        //temp.display();
        //temp = (Client) ClientList.get(0);
        //temp.display();
        //temp = (Client) ClientList.get(1);
        //temp.display();
        //temp = (Client) ClientList.get(2);
        //temp.display();
        ////
        //Client[0].display();
        //Client[1].display();
        //Client[2].display();
        
        Client temp;
        
        for(int x = 0; x < 3; x++){
            temp = Client[x];
            temp.display();
        
            temp = (Client) ClientList.get(x);
            temp.display();
        
            temp = (Client) ClientList.get(temp.getCName());
            temp.display();
        }
    
    }
    
    
    public void runClientProcessing()
    {
        //Run ClientProcessing e.g. call create clients method and display clients method
        createClients();
        DisplayClients();
    }
    
    }

------------------------------------------------------------------------------------------