Last active
          September 30, 2025 13:14 
        
      - 
      
- 
        Save thinkphp/c03c23cacb9135d6c0766013f1e51958 to your computer and use it in GitHub Desktop. 
    equipment_prices.py
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | equipment_prices = { | |
| "1": {"name": "Day chairs", "price": 15.00}, | |
| "2": {"name": "Bed chairs", "price": 25.00}, | |
| "3": {"name": "Bite Alarm (set of 3)", "price": 20.00}, | |
| "4": {"name": "Bite Alarm (single)", "price": 5.00}, | |
| "5": {"name": "Bait Boat", "price": 60.00}, | |
| "6": {"name": "Camping tent", "price": 20.00}, | |
| "7": {"name": "Sleeping bag", "price": 20.00}, | |
| "8": {"name": "Rods (3lb TC)", "price": 10.00}, | |
| "9": {"name": "Rods (Bait runners)", "price": 5.00}, | |
| "10": {"name": "Reels (Bait runners)", "price": 10.00}, | |
| "11": {"name": "Camping Gas stove (Double burner)", "price": 10.00} | |
| } | |
| Customer ID: 101 | |
| Name: John Smith | |
| Phone: 1234567890 | |
| House: 1 | |
| Postcode: AB12 3CD | |
| Card: 1234567890123456 | |
| Equipment: | |
| - 2 x Bed chairs (code 2) | |
| - 1 x Camping tent (code 6) | |
| Nights: 1 | |
| On time: y | |
| Expected: £70.00 | |
| def hire_equipment(): | |
| """ | |
| Subroutine to handle customer hire details (TASK 2) | |
| Collects customer information and equipment hire details | |
| Stores data in customer_records list | |
| """ | |
| # ========== STEP 1: Get customer details ========== | |
| print("\n" + "="*60) | |
| print("CUSTOMER AND HIRE DETAILS") | |
| print("="*60) | |
| customer_id = get_valid_customer_id() | |
| customer_name = get_valid_name() | |
| phone_number = get_valid_phone() | |
| house_number = get_valid_house_number() | |
| postcode = get_valid_postcode() | |
| card_number = get_valid_card() | |
| # ========== STEP 2: Display equipment list ========== | |
| display_equipment_list() | |
| # ========== STEP 3: Get equipment selections ========== | |
| selected_equipment = [] | |
| print("\n--- SELECT EQUIPMENT ---") | |
| while True: | |
| code = get_valid_equipment_code() | |
| # If user enters 0, stop selecting | |
| if code == "0": | |
| # Must have at least one item | |
| if len(selected_equipment) == 0: | |
| print("Error: You must select at least one equipment item.") | |
| continue | |
| break | |
| quantity = get_valid_quantity() | |
| # Create equipment item record | |
| equipment_item = { | |
| 'code': code, | |
| 'name': equipment_prices[code]['name'], | |
| 'price': equipment_prices[code]['price'], | |
| 'quantity': quantity | |
| } | |
| # Add to selected equipment list | |
| selected_equipment.append(equipment_item) | |
| print(f"Added: {quantity} x {equipment_prices[code]['name']}") | |
| # ========== STEP 4: Get hire details ========== | |
| number_of_nights = get_valid_nights() | |
| returned_on_time = get_yes_no("\nWas equipment returned on time (by 2pm)? (y/n): ") | |
| # ========== STEP 5: Calculate costs ========== | |
| total_cost = calculate_cost(selected_equipment, number_of_nights) | |
| # Calculate extra charge for late return | |
| if returned_on_time == 'n': | |
| extra_charge = total_cost * 0.5 | |
| total_cost = total_cost + extra_charge | |
| else: | |
| extra_charge = 0.0 | |
| # ========== STEP 6: Create and store customer record ========== | |
| customer_record = { | |
| 'customer_id': customer_id, | |
| 'customer_name': customer_name, | |
| 'phone_number': phone_number, | |
| 'house_number': house_number, | |
| 'postcode': postcode, | |
| 'card_number': card_number, | |
| 'equipment': selected_equipment, | |
| 'number_of_nights': number_of_nights, | |
| 'returned_on_time': returned_on_time, | |
| 'total_cost': total_cost, | |
| 'extra_charge': extra_charge | |
| } | |
| # Store in global list | |
| customer_records.append(customer_record) | |
| # ========== STEP 7: Display confirmation ========== | |
| print("\n" + "="*60) | |
| print("HIRE CONFIRMATION") | |
| print("="*60) | |
| print(f"Customer ID: {customer_id}") | |
| print(f"Customer Name: {customer_name}") | |
| print(f"Phone: {phone_number}") | |
| print(f"Address: {house_number}, {postcode}") | |
| print(f"Card: {card_number}") | |
| print("\nEquipment Hired:") | |
| print("-"*60) | |
| for item in selected_equipment: | |
| print(f" {item['quantity']} x {item['name']} @ £{item['price']:.2f} each") | |
| print("-"*60) | |
| print(f"Number of Nights: {number_of_nights}") | |
| print(f"Returned on Time: {'Yes' if returned_on_time == 'y' else 'No'}") | |
| print(f"Base Cost: £{total_cost - extra_charge:.2f}") | |
| if extra_charge > 0: | |
| print(f"Late Return Charge: £{extra_charge:.2f}") | |
| print(f"TOTAL COST: £{total_cost:.2f}") | |
| print("="*60) | |
| print("\nHire record saved successfully!") | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment