Question: Please note that the requirements for problem 1 is numbered and listed explicitly. You job is to write the code. Problems 2 and 3 requires

Please note that the requirements for problem 1 is numbered and listed explicitly. You job is to write the code. Problems 2 and 3 requires you to be a little more involved.

From the narratives of problems 2 and 3 , you are expected to extract the requirements one by one , number of requirements like it is in problem 1. Problems 2 and 3 teach you how to extract requirements from a give narrative, the way it appears in real world problem description. Once you extract the requirements, you will write your code in Java using the IDE. You will compile the code, clear all mistakes and paste the code in this document for submissions.

In problem 4 , you are given a set of requirements for the client class and you are to write the code. In problem 5 , you write a single client class that will create objects of the Dog class and the Dog License class within the same tester class. Once again you are given explicit requirements.

PLEASE WRITE CODE IN NETBEANS / ECLIPSE, MAKE SURE THE CODE IS FINISHED FROM START TO END. THANK YOU!

  1. Write a blueprint class that tracks the orders made to vendors in a companys product purchasing system. We will create a class called ProductOrder. The requirements are as follows :

  1. The class ProductOrder has the following private instance variables: productID, orderID, quantityRequested , quantityFulfilled all of types integer. We will need separate variables for quantity requested and quantity fulfilled because the vendors may not be able to fulfill the requests completely.
  2. The class/object model will provide the values of the quantityRequested and quantityFulfilled to the client program. To do this, have proper getters and setters for the instance variables.
  3. The class/object model has method, calculatePayment, that will calculate the pending payments to be made to vendors for the product quantity fulfilled. To do this, the method will receive the payment price as a parameter and multiply this price with the quantityFulfilled to determine the payments that are due. Write a method in the class that will take in a (double) parameter called price and returns the value of the payment due (also a double). This value of payments due is the amount that the company will need to pay to the vendor.
  4. The class/object model has a method called printPendingOrder that will print the number of un-fulfilled orders. The value of balance is given by the difference between quantityRequested and quantityFulfilled. The printPendingOrder method takes in no input parameters and has a void return.
  5. The class/ object model has constructors that will allow default and full-argument overloaded constructors in the client class. Write appropriate default and overloaded constructors .

Answer: Copy and paste the complete code for ProductOrder here:

Problem 2:

You may create a separate(new) package to write the Dog and DogLicense classes of problems 2 and 3.

  1. Write a class that will model a Dog. We are interested in developing an application that will keep track of every Dog in a certain locality. The properties of a Dog that needs to be captured in a Dog class are: name, weight and years, which could be defined as String, int and int respectively. Every Dog entered into the application will be modeled as a Dog object. These properties should be kept secure from tampering and hence, the class will need to encapsulate these properties.

The client programs of the class will access and change these properties using appropriate getters and setters.

The class should have a method called obtainSize , that will return the size of the dog. Size is a string variable and can take the value of small, medium, large . (Size is not an instance variable). The method obtainSize will determine the size based on the following conditions. If the weight is <= 10, the size is small, else if the weight is between 10 and 30 ( inclusive) the size is medium. For all weights more than 30, size is large. The method obtainSize, returns the value of size. This method takes in no argument from the client programs.

The dog class also needs constructors, both default and full-argument overloaded. Whenever a new dog enters the system, the constructors are used to create new dog objects. Those dogs that are new to the system( for example a new puppy) , but dont have a registered credentials, are created using default constructors, and the properties can be set later on. The class should also provide overloaded constructors that can be used to create new Dog objects.

Then, write the class code for Dog class in Java, to meet all the requirements. Make sure your code is error free. Write and compile your code using the IDE. Copy paste your code here.

Problem 3:

  1. The previous problem, we modeled a Dog class for a dog tracking application. In this problem we will model a Dog license for the same application. The Dog license object captures data on the dogs license number, license year, licensing authority etc. We are now planning to create and store dog licenses using a new application. To do this we need to create the required classes and their functions

This dog application will capture these properties in a separate class called DogLicense. Create a class called DogLicense with the following instance variables: licenseNum, licenseYear and name of the type int, int and String, respectively.

The DogLicense class is supposed to keep the instance variables private.

However, these instance variables are to be accessed by the client application. Therefore, the class requires getters and setters for each instance variable, except for setting the licenseNum. The licenseNum is set only once during the lifetime of the DogLicense object using the createLicenseNum method as described below.

Some dogs may not have a license number initially and they may need to be generated later on. To do this, the DogLicense class will have a method called createLicenseNum. This method will take in an integer argument called customID . This method has a void return. This method will assign a value to the instance variable licenseNum = (500*customID)+licenseYear .

The DogLicense class requires a default constructor. Use default values of your choice for the instance variables.

The DogLicense class requires an overloaded constructor with all three 3-arguments.

Answer: In plain English, write all the requirements ( make sure to number them) of the DogLicense class.

Then, write the class code for DogLicense class in Java, to meet all the requirements. Make sure your code is error free. Write and compile your code using the IDE. Copy paste your code here.

Problem 4:

You may write the codes for problems 4 and 5 in the same package that you created the Dog and DogLicense classes

  1. Create a class called TestProductOrder in the same package that you created ProductOrder class in problem 1. The requirements for TestProductOrder class is as given below. Create a main method and write the code for main method as given below:

  1. Create a ProductOrder object called prodOrder1, using the default constructor .
  2. Use the setters on prodOrder1 to set the values of instance variables. (Make sure quantityFulfilled is lesser that quantityRequested)
  3. Prompt the user to provide a value for amount and scan this into a variable called price.
  4. Call the calculatePayments method for prodOrder1 and to this method, pass on the value of price, (obtained from user). Print out the return value of this method call.
  5. Call the printPendingOrder method for prodOrder1.
  6. Prompt the user to provide a new value for quantityFulfilled and use the setter on prodOrder1 to set the new value of quantityFulfilled.
  7. Create a new object called prodOrder2 using the overloaded constructor .
  8. Call the printPendingOrder method for prodOrder2.
  9. Prompt the user to provide a new value of payment amount and scan this into the variable called price.
  10. Call the calculatePayments method for prodOrder2 and to this method, pass on the value of price, (obtained from user).Print out the return value of this method call.
  11. Use the setter and change the value of quantityRequested by increasing the orders requested to new value.
  12. Call printPendingOrder method for cashReg2 to print out the pending orders.

Answer: copy / paste your code below. Also provide a screen shot of the results. The outputs should be formatted such that each out put line should describe what is the output stands for.

Problem 5:

5. Create a tester class called DogApplication in same package as you have create the Dog and DogLicense classes. In the DogApplication class , have a main method in which you will test the Dog and Dog License objects one by one.

  1. Create another Dog object dog1 using the overloaded constructors. Provide arguments of your choice, but make sure they are in the same order as you have specified in the constructors
  2. Using getters, obtain dog1s name, weight and years and print out the details of dog1 on the output. Please make sure to include comments.
  3. Create a DogLicense object called dog1License using the default constructor of DogLicense class.
  4. Using the getter , obtain dog1s name and pass on this value ( the variable ) to set the name of dog1License object. To do this you will need use the getter to get dog1s name and save the return in a name variable. Then pass on this name variable to the setter of dog1Lcenses setName setter method.
  5. Using the getter , obtain dog1s years. Subtract that value of dog1s years from 2018 and use the result to set the variable called licenseYear. For example if dogs years is 5, then license year is 2018-5 = 2013. Call the setter, (pass on the value of licenseYear ) for dog1License to set the value of its licenseYear instance variable.
  6. Prompt the user to enter a 4 digit number and store this value in a variable called customID.
  7. Call the method called createLicenseNum for dog1Liscense and pass on this method, the value of customID.
  8. Using getters obtain the values of all instance variables of dog1License and print them on the output with comments.

Answer: copy / paste your code below. Also provide a screen shot of the results. The outputs should be formatted such that each out put line should describe what the output stands for.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!