Пример #1
0
        /**
         * Creates a new ServiceMaintainer control object
         */
        public ServiceMaintainer()
        {
            try
            {
                //Create and open the service collection
                services = new Services();
                services.open();

                //Create a user interface and set up menu
                ui = new UserInterface();
                String menuText = "1.\tAdd a New Service\n" +
                                  "2.\tEdit a Service\n" +
                                  "3.\tDelete a Service\n" +
                                  "4.\tQuit\n";

                int choice;
                do
                {
                    ui.message("\t\t\tMaintain Services\n\n");
                    choice = ui.menu(menuText);  //display menu and get choice
                    switch (choice)
                    {
                    case 1: addService(); break;

                    case 2: editService(); break;

                    case 3: deleteService(); break;

                    case 4: break;

                    default: ui.errorMessage("Invalid choice.  Please re-enter."); break;
                    }
                } while (choice != 4);

                //close the service collection
                services.close();
            }
            catch (Exception ex)  //Error in file format
            {
                ui.errorMessage(ex.Message);
                return;
            }
            //catch (FileNotFoundException ex)
            //{
            //    //occurs if the file cannot be created
            //    ui.errorMessage(ex.getMessage());
            //}
        }//default constructor
        /**
         * Creates a new ProviderInterface.
         */
        public ProviderInterface()
        {
            ui = new UserInterface();

            //Start use case Manage Session
            logon();

            String menuText = "\t1. Verify Member/Submit Claim\n"
                              + "\t2. Request Provider Directory\n"
                              + "\t3. Quit\n";

            int choice;

            do
            {
                //display menu and read choice
                ui.message("\n\t\t\tProvider Subsystem\n");
                choice = ui.menu(menuText);
                switch (choice)
                {
                //Use case Verify Member followed optionally by Submit claim
                case 1: verifyMember(); break;

                //Use case Receive Provider Directory
                case 2: receiveDirectory(); break;

                case 3: break;

                default: ui.errorMessage("Invalid choice.  Please re-enter."); break;
                }
            } while (choice != 3);
        }// default Constructor
        /**
         * Creates a new Operator Interface
         */
        public OperatorInterface()
        {
            UserInterface ui       = new UserInterface();
            String        menuText = "1.\tMaintain Provider\n"
                                     + "2.\tMaintain Member\n"
                                     + "3.\tMaintain Service\n"
                                     + "4.\tQuit\n";

            int choice;

            do
            {
                ui.message("\t\t\tMaintenance Subsystem\n\n");
                //displays menu and read choice
                choice = ui.menu(menuText);
                switch (choice)
                {
                //Create the control object required for selected use case
                //Use case Maintain Provider
                case 1: new ProviderMaintainer(); break;

                //Use case Maintain Member
                case 2: new MemberMaintainer(); break;

                //Use case Maintain Service
                case 3: new ServiceMaintainer(); break;

                //Quit
                case 4: break;

                default: ui.errorMessage("Invalid choice.  Please re-enter."); break;
                }
            } while (choice != 4);
        }// default Constructor
        /**
         * Creates a new Reporting Subsystem
         */
        public ManagerInterface()
        {
            //set up user interface and menu
            ui = new UserInterface();
            String menuText = "1.\tProvider Report\n" +
                              "2.\tMember Report\n" +
                              "3.\tAccounts Payable Report\n" +
                              "4.\tQuit\n";

            int choice;

            do
            {
                ui.message("\t\t\tReporting Subsystem\n");

                //display menu and get choice
                choice = ui.menu(menuText);
                switch (choice)
                {
                //use case Produce Provider Report
                case 1: providerReport(); break;

                //use case Produce Member Report
                case 2: memberReport(); break;

                //use case Produce Accounts Payable Report
                case 3: accountsPayableReport(); break;

                //Quit
                case 4: break;

                default: ui.errorMessage("Invalid choice.  Please re-enter."); break;
                }
            } while (choice != 4);
        }// default Constructor
Пример #5
0
        /**
         * Creates a new ProviderMaintainer control object
         */
        public ProviderMaintainer()
        {
            try
            {
                //create and open the provider collection
                providers = new Providers();
                providers.open();

                //set up menu for user interface
                ui = new UserInterface();
                String menuText = "1.\tAdd a New Provider\n" +
                                  "2.\tEdit a Provider\n" +
                                  "3.\tDelete a Provider\n" +
                                  "4.\tQuit\n";

                int choice;
                do
                {
                    ui.message("\t\t\tMaintain Providers\n\n");
                    //display menu and read choice
                    choice = ui.menu(menuText);
                    switch (choice)
                    {
                    case 1: addProvider(); break;

                    case 2: editProvider(); break;

                    case 3: deleteProvider(); break;

                    case 4: break;

                    default: ui.errorMessage("Invalid choice.  Please re-enter."); break;
                    }
                } while (choice != 4);

                //close provider collection
                providers.close();
            }
            catch (Exception ex)
            {
                //occurs if the file cannot be created
                ui.errorMessage(ex.Message);
            }
        }//default constructor
Пример #6
0
        }//deleteService

        //Utility method to get user input and update attributes of a service
        private void updateService(UserInterface ui, Service aService
                                   , bool retainOldValue)
        {
            try
            {
                String input;

                //Get value for code if it has not already been set
                if (aService.getCode() == null)  //code may not be changed
                {
                    input = ui.promptForString("Code: ");
                    aService.setCode(input);
                }

                //get value for name
                input = ui.promptForString("Name: ");
                if (input.Length == 0 && retainOldValue)
                {
                    aService.setName(aService.getName());    //ensure valid name
                }
                else
                {
                    aService.setName(input);
                }

                //get value for fee
                double fee;
                if (retainOldValue)
                {
                    fee = ui.promptForDouble("Fee: ", aService.getFee());
                }
                else
                {
                    fee = ui.promptForDouble("Fee: ");
                }
                aService.setFee(fee);
            }
            catch (ArgumentException ex)
            {
                ui.errorMessage(ex.Message);
                ui.message("Current details:");
                ui.message(aService.toFormattedString());
                ui.message("\nPlease repeat input.  "
                           + "Press Enter for details that are correct.");
                updateService(ui, aService, true);    //Give the user another chance
            }
        }//updateService
Пример #7
0
        /**
         * Creates a new ChocAnSystem.
         */
        public ChocAnSystem()
        {
            UserInterface ui = new UserInterface();

            string menuText = "1.\tProvider Subsystem\n" +
                              "2.\tMaintenance Subsystem\n" +
                              "3.\tReporting Subsystem\n" +
                              "4.\tAccounting Procedure\n" +
                              "5.\tQuit\n";

            int choice;

            try
            {
                do
                {
                    ui.message("\t\t\tChocoholics Anonymous\n\n");

                    //display the menu and read the choice
                    choice = ui.menu(menuText);
                    switch (choice)
                    {
                    //Start subsystem chosen
                    case 1: new ProviderInterface(); break;

                    case 2: new OperatorInterface(); break;

                    case 3: new ManagerInterface(); break;

                    case 4: new SchedulerInterface(); break;

                    case 5: break;

                    default: ui.errorMessage("Invalid choice.  Please re-enter."); break;
                    }
                } while (choice != 5);
            }
            catch (Exception)
            {
                ui.message("\nEnd of test run.\n");
            }
        }//default constructor
Пример #8
0
        }//default constructor

        /** Prompts the user for the new values with which to update a person.
         *  @param ui the user interface with which to communicate with the user
         *  @param aPerson the person object to update
         *  @param retainOldValue if true, the current value of an attribute is
         *								  retained if the user does not specify a new value.
         *                        If false, and a value is required for the
         *                        attribute, the user will be prompted repeatedly
         *                        to enter a value until the value is valid.
         */
        public void updatePerson(UserInterface ui, Person aPerson
                                 , bool retainOldValue)
        {
            try
            {
                if (retainOldValue)
                {
                    ui.message("\nEnter new values.  "
                               + "Press Enter for values that are correct.");
                }
                String input = ui.promptForString("\nName: ");
                if (input.Length == 0 && retainOldValue)
                {
                    aPerson.setName(aPerson.getName());     //ensure valid name
                }
                else
                {
                    aPerson.setName(input);
                }
                input = ui.promptForString("Street Address: ");
                if (input.Length == 0 && retainOldValue)
                {
                }                                            //retain old value
                else
                {
                    aPerson.setStreet(input);
                }
                input = ui.promptForString("City: ");
                if (input.Length == 0 && retainOldValue)
                {
                }                                            //retain old value
                else
                {
                    aPerson.setCity(input);
                }
                input = ui.promptForString("State: ");
                if (input.Length == 0 && retainOldValue)
                {
                }                                            //retain old value
                else
                {
                    aPerson.setState(input);
                }
                input = ui.promptForString("Zip Code: ");
                if (input.Length == 0 && retainOldValue)
                {
                }                                            //retain old value
                else
                {
                    aPerson.setZip(input);
                }
                input = ui.promptForString("Email: ");
                if (input.Length == 0 && retainOldValue)
                {
                }                                            //retain old value
                else
                {
                    aPerson.setEmail(input);
                }
            }
            catch (ArgumentException ex)
            {
                ui.errorMessage(ex.Message);
                ui.message("Current details:\n");
                ui.message(aPerson.toFormattedString());
                ui.message("\nPlease repeat input.\n");
                updatePerson(ui, aPerson, true);    //Give the user another chance
            }
        }//updatePerson
Пример #9
0
        /** Creates a new Claim Submitter object
         *  @param theProvider the provider submitting the claim
         *  @param theMember the member to whom the service was provided
         */
        public ClaimSubmitter(Provider theProvider, Member theMember)
        {
            try
            {
                ui = new UserInterface();

                services = new Services();
                claims   = new Claims();
                services.open();
                claims.open();

                //get the service date
                DateTime serviceDate = ui.promptForDate
                                           ("Service Date (" + UserInterface.DATE_FORMAT + "): ");

                //get the correct service
                Service theService  = null;
                bool    correctCode = false;
                do
                {
                    //get the service code
                    String serviceCode = ui.promptForString("Service Code: ");
                    theService = services.find(serviceCode);
                    if (theService == null)
                    {
                        ui.errorMessage("Invalid code.  Please re-enter.");
                    }
                    else
                    {
                        //confirm the service
                        String answer = ui.promptForString("Service: "
                                                           + theService.getName()
                                                           + "  \nIs this correct? (Y)es or (N)o: ");
                        if (answer != null && answer.Length >= 1 &&
                            Char.ToUpper(answer[0]) == 'Y')
                        {
                            correctCode = true;
                        }
                    }
                } while (!correctCode);


                //Create new claim.  The constructor initializes
                //the submission date and time with the system time.
                Claim aClaim = new Claim(theService.getCode(),
                                         theProvider.getNumber(), theMember.getNumber(),
                                         serviceDate);
                claims.add(aClaim);
                //Display success confirmation and service fee
                ui.message("Your claim has been submitted successfully.");
                ui.message("Service fee due to you: "
                           + ui.formatAsCurrency(theService.getFee()));

                services.close();
                claims.close();
            }
            catch (Exception ex)
            {
                //File format is incorrect
                ui.errorMessage(ex.Message);
            }
        }//default constructor
Пример #10
0
        /**
         * Creates a new SchedulerInterface which then runs the accounting procedure.
         */
        public SchedulerInterface()
        {
            //for communciation with the tester
            UserInterface ui = new UserInterface();

            ui.message("\nRunning the accounting procedure ...\n");

            //Use today's date for all reports
            DateTime now = DateTime.Today;

            try
            {
                //Generate provider reports
                ui.message("Generating the providers' reports ...");
                Providers providers = new Providers();
                providers.open();
                List <Person> allProviders = providers.getAll();
                foreach (Person person in allProviders)
                {
                    Provider provider                 = (Provider)person;
                    ProviderReportGenerator gen       = new ProviderReportGenerator(provider, now);
                    ProviderReport          theReport = gen.getReport();
                    if (theReport.getDetailCount() > 0)
                    {
                        theReport.sendByEmail(provider.getName());
                    }
                }
                providers.close();

                //Generate member reports
                ui.message("Generating the members' reports ...");
                Members members = new Members();
                members.open();
                List <Person> allMembers = members.getAll();
                foreach (Person person in allMembers)
                {
                    Member member                   = (Member)person;
                    MemberReportGenerator gen       = new MemberReportGenerator(member, now);
                    MemberReport          theReport = gen.getReport();
                    if (theReport.getDetailCount() > 0)
                    {
                        theReport.sendByEmail(member.getName());
                    }
                }
                members.close();

                //Generate accounts payable report
                ui.message("Generating the accounts payable report ...");
                AccountsPayableReportGenerator generator
                    = new AccountsPayableReportGenerator(now);
                generator.getReport().sendByEmail("Accounts Payable");

                //Generate EFT data
                ui.message("Generating the EFT data ...");
                EFTReportGenerator eftGenerator = new EFTReportGenerator(now);
                eftGenerator.getReport().print("EFT Data");

                ui.message("\nAccounting procedure completed successfully.\n\n");
            }
            catch (FileNotFoundException ex)
            {
                //occurs if a file cannot be created
                ui.errorMessage(ex.Message);
            }
        }//default constructor