Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Programming Assignment 01 Review of Classes, Objects, Arrays, and Enhanced for Looping Contents Giveni Tasks -- - Requirements ResidencePolicy.java.. Test_ResidencePolicy.java...... Testing Your Code..... .. Submitting

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Programming Assignment 01 Review of Classes, Objects, Arrays, and Enhanced for Looping Contents Giveni Tasks -- - Requirements ResidencePolicy.java.. Test_ResidencePolicy.java...... Testing Your Code..... .. Submitting Your Work ........ Given: . . UML Class Diagram of ResidencePolicy (on Blackboard) Test harness shell: Test_ResidencePolicy.java fon Blackboard) These instructions Sample output on Blackboard) Grading Rubric (on Blackboard) Tasks: 1. Write the Java code to describe class ResidencePolicy in accordance with the provided UML Claw Diagram and the published Basic Coding Standards document 2. Complete the code for Test_ResidencePolicy.java such that it successfully serves to test the class ResidencePolicy and meets the specific requirements listed below. Requirements: ResidencePolicy.java 1. Code the Java class ResidencePolicy according the UML Class Diagram provided and the instructions included here. 2. The class ResidencePolicy will require two constructors a. The default or null constructor will accept no parameters and will produce a ResidencePolicy object having no established instance variable values. b. The full constructor will accept five (5) values. The full constructor will call the appropriate "set" methods to assign the received values to the appropriate instance variables. NOTE: Direct assignment of instance variable values effectively invalidates the full constructor. In such a case, the student will lose al points assigned for the full constructor. 3. Write "set" methods for all instance variables a. Rag all "set" methods as "final methods. b. Each "set" method will accept the appropriate data type value and assign it to the appropriate instance variable. c "Set" methods do not return values. d. "Ser" methods must not contain any code other than that required to set a value for the given instance variable. e. Naming of "set" methods must be according to published standards. 4. "Get" methods will be written for all instance variables. a. "Get" methods are flagged as "final methods. b. "Get" methods accept no parameters c Each "get" method must return a type appropriate to the instance variable with which it is associated. d. "Ger" methods will not contain any code other than that required to set a value for the given instance variable. e. Naming of "get" methods must be according to published standards. 5. Method txt Type will return a String translation of the coded Type Instance values d. type l. return "HOMEOWNERS b. If type = 2:return "RENTERS c type has an invalid value (less than 1 or greater than 2), return "UNKNOWN" 6. Method toString G. Retums a reference to a formatted String object containing a description of the ResidencePolicy object as shown in the UML Class Diagram b. Currency formatting must be used for printing currency values. c. Must use "get" and other methods as appropriate to retrieve Instance variable values NOTE: Direct reference to instance variables in the tostring method will invalidate the method, resulting in zero points for that code. d. Use the format method to format the returned String object correctly/appropriately. 7. Do not include any unnecessary or meeded code. 8. Use Basic Coding Standards. This specifically applies to the commenting of code. Test_ResidencePolicy.java The assignment folder includes the basic code for testing your ResidencePolicy class. Add code to complete the following functions 1. Each instantiated ResidencePolicy object will be stored in an array. To accomplish this, you must declare a one-dimensional array structure to hold ResidencePolicy object. a. Name the array objectArray. b. Declare the array to hold six (6) ResidencePolicy objects. 2. In the printToStrings method, complete the enhanced for loop statement a. Use the name oneObject as the local reference to the current ResidencePolicy object. b. Do not change the System.out.printf statement in any way. 3. Do not add any unneeded code. 4. Do add comments as appropriate. 5. Follow Basic Coding Standards. Testing Your Code Be wre to test your code thoroughly. While a structure for the test harness has been provided and your test harness will be validated, will do additional testing as well. Your code must meet requirements in those additional test cases. Expected Output - PAO1 Submission passes minimal standards check. List of ResidencePolicy Objects in Array objectArray null owns ResidencePolicy 0, a(n) UNKNOWN policy, issued by null, at physical address null, for a premium of $0.00. Ted Arroway owns ResidencePolicy 658542, a(n) HOMEOWNERS policy, issued by MUT, at physical address 2487 Morning Glory, for a premium of $2,563.58. Eleanor Arroway owns ResidencePolicy 987420, a(n) RENTERS policy, issued by MUT, at physical address 247 Desert Sky D541, for a premium of $263.08. Drumlin, LLC owns ResidencePolicy 983214, a(n) HOMEOWNERS policy, issued by MUT, at physical address 13 Sulky Lane, for a premium of $5,673.98. Hadden Industries owns ResidencePolicy 147569, a(n) HOMEOWNERS policy, issued by LLOYDS, at physical address 37 Betelguese Penthouse, for a premium of $12,563.58. Palmer Joss owns ResidencePolicy 831726, a(n) HOMEOWNERS policy, issued by CIC, at physical address 984 Ave K Apt 8942, for a premium of $754.36. Attributes private owner: String private group: String private number: int private address: String private type: int ResidencePolicy Notes Policy owner's full, legal name A short alphanumeric code identify the "group" by which this policy is issued A unique numeric identifier for this policy The physical address associated with the policyle.g. 1 UTSA Circle) Integer code indicated type of policy: 1: Homeowners 2: Renters Annual premium amount for policy private premium: double Operations public ResidencePolicy ): ResidencePolicy Description Null constructor; establishes no instance variable values. Returns a reference to a Policy object with neutral default values. Constructor accepts an argument or parameter per instance variable, calls set methods and establishes instance variable values as appropria:e. Returns a reference to a fully instantiated Policy object. public ResidencePolicy String own, String grp. int nbr String addr, int kind, double prem): ResidencePolicy public setOwner(String own): void public set Group String grp: void public set Numberint nbrl: void public set Address String addr: void public set type int type): void public set Premium double prem): void Accepts a String reference; assigns reference to owner instance variable Accepts a String reference; assigns reference to group instance variable Accepts an int value; assigns reference to number instance variable Accepts an String reference; assigns value to address instance variable Accepts an integer value; assigns value to type instance variable Accepts a double value; assigns value to premium instance variable public getOwner(): String public getGroup(): String public get Number(); int public get Address : String public getTypel): int public get Premium 1: double Returns a reference to the Strine obiect holding owner value Returns a reference to the String object holding group value Returns a copy of the int value of the number instance variable Retums a reference to the String object holding address value Returns the int value associated with type value Returns the double value representing the premium amount public txt Type : String Retumsa String object containing a clear text "translation of the type value see notes on type instance variable) public toString(): String Returns a String reference to a formatted description of the Policy object: owner owns ResidencePolicy number, a(n) txtPol Type policy, issued by group, at physical address address, for a premium of premium. NOTES: When output in the toString method, premium must displayed with correct currency formatting, including thousands separator

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions