DPIT121 – Lab Exercise 3In lab 3, you will continue on another iteration for the same scenario from lab 1 and 2.1) Add these methods to your InsurancePolicy class: 0.25 marks- static ArrayList...

1 answer below »
continuation of 113599 order,please have comments and written where lab 3 and assignment 1 starts as comment


DPIT121 – Lab Exercise 3 In lab 3, you will continue on another iteration for the same scenario from lab 1 and 2. 1) Add these methods to your InsurancePolicy class: 0.25 marks - static ArrayList filterByExpiryDate (ArrayList policies, MyDate date) // which filter a list of policies and creates a filtered list of policies that are expired by the given date. To do this add a new method Boolean isExpired( MyDate expiryDate) to your MyDate class, which compares the given date with the object and returns false if the date is before that given expiryDate or true it is after that date. 2) Add these methods to your User class: 0.75 marks: 0.25 marks for each method - boolean createThirdPartyPolicy( String policyHolderName, int id, Car car, int numberOfClaims, MyDate expiryDate, String comments ) // creates a Third-Party Policy and adds it to the list of the user’s policies, returns false if the id is not unique. Create an object from ThirdPartyPolicy and call addPolicy method to add it to the list - boolean createComprehensivePolicy( String policyHolderName, int id, Car car, int numberOfClaims, MyDate expiryDate, int driverAge, int level) // creates a Comprehensive Policy and adds it to the list of the user’s policies, returns false if the id is not unique. Create an object from ComprehensivePolicy and call addPolicy method to add it to the list - ArrayList filterByExpiryDate (MyDate date) // filters the policies and returns a list of policies with the expiry date before the given date by calling the corresponding static method inside InsurancePolicy 3) Write a class InsuaranceCompnay with the following fields and methods: 2 marks. 0.1 mark for each method - String name; · private ArrayListusers // list of all the users having a policy with the company · private String adminUsername · private String adminPassword; · private int flatRate; · Constructors, mutators (set methods) and assessors (get methods) if necessary · boolean validateAdmin( String username, String password) // returns true if username and password matches the admin login details · boolean addUser(User user) // adds the user to users list if userID is unique, if not returns false · Boolean addUser(String name, int userID, Address address) // creates and adds the User to users list if userID is unique, if not returns false. Create a user object and reuse the addUser(User user) method · User findUser(int userID) // finds the user with the given ID or returns null if user does not exist · boolean addPolicy (int userID, InsurancePolicy policy) // finds the user with the given userID by using findUser method and adds the policy to the user, unsuccessful if userID does not exist or policy is not unique · InsurancePolicy findPolicy (int userID ,int policyID) // finds the insurance policy for the given userID and returns it. Returns null if userID does not exist or policyID does not exist for the given user · void printPolicies(int userID) // prints the user information and all the policies for the given userID · void print() // prints all the users and for each user all the policies by calling User. PrintPolicies(int flatRate) · String toString() // coverts the whole object to string ( including all the users and their policies). Hint: call toString() for users in a loop and concatenate them · boolean createThirdPartyPolicy(int userID, String policyHolderName, int id, Car car, int numberOfClaims, MyDate expiryDate, String comments) // finds the user with the given userID (by calling findUser) and calls the createThirdPartyPolicy for that user. Returns false if the user does not exist or if User.createThirdPartyPolicy returns false · boolean createComprehensivePolicy( int userID, String policyHolderName, int id, Car car, int numberOfClaims, MyDate expiryDate, int driverAge, int level ) // finds the user with the given userID (by calling findUser) and calls the createComprehensivePolicy for that user. Returns false if the user does not exist or if User.createComprehensivePolicy returns false · double calcTotalPayments(int userID) // returns the total premium payments for the given user · double calcTotalPayments () // returns the total premium payments for all the users in the company · boolean carPriceRise (int userID, double risePercent) // calls carPriceRiseAll method for the given user. Returns false if user cannot be found · void carPriceRise(double risePercent) // Raise the price of all cars for all users in the company · ArrayList allPolicies () // returns a list of all the policies in the company across all users · ArrayList filterByCarModel (int userID, String carModel) // find the user by calling findUser and calls filterByCarModel for the given user · ArrayList filterByExpiryDate (int userID, MyDate date) // find the user by calling findUser and calls filterByExpiryDate for the given user · ArrayList filterByCarModel (String carModel) // filters all the policies in the company by carModel across all users. Iterate over a loop for all users and for each user call the filterByCarModel method and add all the results together for a global list including all users. · ArrayList filterByExpiryDate (MyDate date) // filters all the policies in the company by ExpiryDate across all users. The same as above 4) Add this test code to your main: 2 marks 1- You have one user from lab 2. Create few more users and more policies and one insuranceCompnay in your main 2- Login to the insuranceCompany once successful and once not successful with proper prompting 3- Add users to the insuranceCompany by using both versions of addUser() and at least once not successful with prompting 4- Add several polices to the users by calling addPolicy (int userID, InsurancePolicy policy), at least once not successful with wrong userID and once with duplicate policy with prompting 5- Add several polices to some users by calling createThirdPartyPolicy() and createComprehensivePolicy() , at least once not successful with wrong userID and once with duplicate policy ID with prompting 6- Ask customer to enter a userID and print the user and all of his policies by using methods inside insuranceCompany 7- Ask customer to enter a userID and policyID and find a policy with the given policyID for that userID by calling findPolicy (int userID ,int policyID) and then print the policy. 8- Print all the users inside the insuranceCompany 9- Raise the price of cars for all users and policies by 10% and print the users again 10- Print the total premium payments for a given userID by calling calcTotalPayments (int userID) 11- Print the total premium payments for all users in the company 12- Call allPolicies() for the insuranceCompany and store it in an ArrayList and print the list by using InsurancePolicy.printPolicies() 13- For a given userID and expiry date call filterByExpiryDate (int userID, MyDate date), store the filtered list and print the list by using InsurancePolicy.printPolicies() 14- For a given car model call insuranceCompany.filterByCarModel (String carModel) and print the filtered list 15- Ask user to enter a date (year, month, and day) and call filterByExpiryDate (MyDate date) and print the filtered list 16- Find a user with the given ID (valid) and save it in a user object. Ask user to provide a new address and change the current address for the given user DPIT121 – Assignment I In Assignment I, you will continue on another iteration for the same scenario from lab 1, 2, and 3. If you have not finished those labs, you have time to work on them and finalize your assignment I. We can consider lab 1 to 3 as internal iterations or Scrum Sprints inside the company and Assignment I as a phase of project delivery to the customer. Assignment I has three levels of completion: Core, Standard, and Advanced. You should completely finish a level before attempting the following level. Core Level: 6 marks to be marked in Week 4 or Week 5 Standard Level: 9 marks to be marked in Week 4 or Week 5 Advanced Level: 12 marks to be marked in Week 4 or Week 5 Core Level: You need to finish all the requirements of lab 1 to 3 including all the classes, methods and the test code. In addition, you need to do the following tasks: 1) Comment out the scanner and user input from your test code that was required in lab 2 and 3. You need to write a proper Test Case (refer to Lectures) and modify your test code to implement the test case. Test code should call all the methods across all classes. To validate your program, write your output expectations in the test case (You may use excel) and compare the output of the test code with your expectation. Include the test case in your submission. You need to justify and convince me as your customer that the output is correct based on your test case and expectations. Note that the test case should not include any user interaction (Scanner) and has to follow a proper story. 1 mark 2) Draw a UML class diagram for your program by using UMLet or any other tools. 1 mark 3) Draw a UML Sequence Diagram for ArrayList filterByExpiryDate (int userID, MyDate date) in InsuranceCompany class. 1 mark 4) Design and implement a basic command based console User Interface. (See the sample code in week 3). The program asks company admin to enter the username and password to log in to the system. After successful log in the program shows 9 options: 3 marks Option 1: Test code: To run the test code based on your test case Option 2: Create User: To get the information from admin and creates a user Option 3: Create ThirdParty Policy: To get the information of a policy and a user id from admin and creates a ThirdPartyPolicy for the given user. Prints an error message if not successful. Option 4: Create Comprehensive Policy: To get the information of a policy and a user id from admin and creates a Comprehensive Policy for the given user. Prints an error message if not successful. Option 5: Print User Information: To get a user ID from user and prints the user information (including all user policies). Prints an error message if user ID is not found. Option 6: Filter by Car Model: To get a car model from admin and filters and prints all the policies in the system for that car model as well as the total payment for the filtered policies. Option 7: Filter by Expiry Date: To get a date and a user id from admin and filters and prints all the policies belong to that user and expiring by the given date. Option 8: Update Address: To get a user id and address information and updates the address of the given suer Option 9: Log Out Play with your UI to be sure that all options are working properly. Remember that you already created few users and policies in your test code. Standard Level: 1- You need to add new methods to your class InsuranceCompany for a data aggregation report. The report is the total premium payments of all users per city (from User.address). · ArrayList populateDistinctCityNames() //goes through all the users and populate a list of distinct city names for all users and returns it as a list. · double getTotalPaymentForCity(String city) // returns the total premium payment for the given city across all users. · ArrayList getTotalPaymentPerCity(ArrayList cities) // aggregates the total premium payments for each city in the list and returns it as a double list with the same order as city names. This method calls getTotalPaymentForCity (String city) · reportPaymentPerCity( ArrayList cities, ArrayList payments, // generates the report as follow: City Name Total Premium Payment Wollongong $10,500.00 Sydney $45,980.00 … Assuming that there are 110 users with the city=”Wollongong” and the total of payments for all of their policies is $10,500 * Update your test code to test these extra methods. 2- Update the text based menu as below: The Main Menu has 3 options: Option 1: Admin Login. Then it prompts to get admin username and password and if login is successful it shows the Admin Menu if not it shows an error message and shows the main menu again. Option 2: User Login. It shows the User Menu Option 3: exit the program Admin Menu has all 9 options the same as core. Add options to do the data aggregation reports. User Menu has options for the methods inside User class such as Add a Policy, print a Policy, change the address, etc Note: Each menu is displayed again after each report/task till user enters the option to log out and returns to the main menu. After each task a message “please press any key to continue” will be displayed and after the user presses a key the menu will be displayed again. Advanced Level: Add these functionalities to your code as well as UI: 1- User and admin to be able to remove a policy from a user 2- User ID to be automatically generated (incrementally). Hint: have a static int count in the class and increment it 3- Admin to be able to remove a user by providing the user ID. 4- Admin to be able to change the admin password 5- You need to add new methods to your class User and InsuranceCompany for another data aggregation report. The report is the count, total and average of premium payments per CarModel across all the polices a user holds and across all the users in the company Add
Answered 2 days AfterNov 21, 2022

Answer To: DPIT121 – Lab Exercise 3In lab 3, you will continue on another iteration for the same scenario...

Aditi answered on Nov 24 2022
43 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here