Review of classes-objects-arrays and enhance for looping

Assignment Help JAVA Programming
Reference no: EM13763255

Review of Classes, Objects, Arrays, and Enhance for Looping

Given: UML Diagram of class Produce

Test Harness code: ProcessProduce.java

These instructions

Tasks:

1. Write Java code for class Produce that meets the listed requirements

2. Complete code for the ProcessProduce.java test harness as instructed below

Requirements:

Class Produce

1. Code Java class Produce according to the UML provided and the instructions included here.

2. The class Produce will require two constructors

a. The default constructor (accepting no parameters) will instantiate a Produce object with the following values:

prodName = Unspecified

prodPrice = 0.0

prodInv = 0.0

b. The second constructor will accept a String object and two double type parameters and instantiate a Produce object based on those parameters:

c. Constructors will call the appropriate "set" methods to assign values to the instance variables. NOTE: Direct assignment of instance variable values effectively invalidates the constructor, i.e., the student will score a zero for that portion of the assignment.

3. "Set" methods will be written for all instance variables

a. Each "set" method will accept the appropriate data type value and assign it to the appropriate instance variable

b. "Set" methods will not return any value

c. "Set" methods will not contain any code other than that required to set a value for the given instance variable

4. "Get" methods will be written for all instance variables

a. Each "get" method will have a return type appropriate to the data type of the instance variable

b. "Get" methods do not accept any input parameters or values

c. "Get" methods will not contain any code other than that required to return the value of the given instance variable

5. Method toString

a. Will return a String object containing all object instance variable values and formatted as follows:

%f pounds of %s at a price of %f per pound/n

where the first "%f" represents the inventory in pounds, the "%s" represents the name of the produce type, and the second "%f" represents the price per pound for the produce type

b. The toString method will call other class methods to retrieve or derive the needed values. NOTE: Direct reference to instance variable values effectively invalidates the constructor, i.e., the student will score a zero for that portion of the assignment.

c. The toString method will use method format to format the returned String object

6. There must be no unneeded (not related to one of the requirements) code.

7. As always, all guidelines in the Basic Coding Standards will be followed. Please note that this specifically includes required code comments.

ProcessProduce Java Code

The basic code provided to you will allow you to test your Produce class. You will add code to complete the following functions:

1. Each instantiated Produce object will be stored in an array. To accomplish this, you will need to do the following:

a. Declare an Array structure, one-dimensional, to hold the instantiated objects.

b. Set the size of the array to contain 5 elements.

c. Add each new Produce object to the array as it is instantiated. (Hint: this can be accomplished in a single statement that instantiates the object and assigns the new object to a position in the array structure.)

d. You will instantiate 5 Produce objects and insert them into the array structure.

e. NOTE: It is not necessary to prompt a user for input - you may simply include the test data in the object instantiation statements

2. Once all Produce objects have been instantiated and inserted into the Array structure, use an enhanced for loop structure to display the to String results for each object to the screen.

3. There must be no unneeded (not related to one of the requirements) code.

4. As always, all guidelines in the Basic Coding Standards will be followed. Please note that this specifically includes required code comments.

Reference no: EM13763255

Questions Cloud

Type of lease-amortization schedule : Delphi Leasing Company leases a new machine that has a cost and fair value of $225,000 to Lindy Corporation on a 5-year noncancelable contract.
Lessor entries-sales-type lease-bench inc : Bench Inc., an equipment manufacturer, leased a machine to Unicycle Company on January 1, 2014. The lease is for a 6-year period and requires equal annual payments of $41,747 at the beginning of each year.
Lessee-lessor entries-sales-type lease : On January 1, 2014, Global Corporation leased equipment to Local Inc. The following information pertains to this lease.
Concepts of class and individual characteristics : Your analysis must reference specific tests, histological staining, microscopes, and other equipment or techniques that should be used.
Review of classes-objects-arrays and enhance for looping : Write Java code for class Produce that meets the listed requirements
Both fiscal and monetary policy affect the money supply : The Tax Foundation says this is because of economic growth leading to higher incomes and higher taxes.
Lessor entries with bargain purchase option : A lease agreement between Earth Leasing Corporation and New Moon Company.
Identify a social cause that is important to you : you will identify a social cause that is important to you. You will describe this cause (what you want changed in the world or society) and some specific ways people could help or take action.
Computation of rental-journal entries for lessor : Horizon Leasing Inc. signs an agreement on January 1, 2014, to lease equipment to one of its customers. The following information relates to this agreement.

Reviews

Write a Review

JAVA Programming Questions & Answers

  What is the paintcomponent method how is it used in java

q1. what is the paintcomponent method? how is it used in java graphics? how does a program intentionally cause the

  What is an illustration of a javascriptreg framework in the

what is an example of a javascriptreg framework? in the framework you have described what is an example of an

  Describe the equivalence classes

Prove that these relations on the set of all functions from Z to Z are equivalence relations. Describe the equivalence classes.

  Calculate the premium and multiply the value of the object

Implement all the four Java classes described with the correct inheritance of abstract classes. Calculate the premium and multiply the value of the object being insured by the corresponding RATE. See the RATE tables above.

  Can linear search algorithm be encoded using recursion

Determine the average amount of time people spend waiting for tables and provide examples from the "real world" of unsorted lists, sorted lists, indexed lists, lists that permit duplicate elements, and lists that do not permit duplicate elements

  Your task in this assignment is to develop a graphical user

your task in this assignment is to develop a graphical user interface based java program that can communicate with a

  Using an array in java

Using an array in Java - have a list of keywords from a web service and have to print out the list of keywords on the screen with one keyword on each line. This is my code

  You are a mighty warrior and armed with your trusty bow and

you are a mighty warrior and armed with your trusty bow and 3 arrows you enter the caves in search of the mighty

  What is the full path the to location of the web application

suppose that you are creating a java web application named "cset-test" consisting of a JSP file named "main.jsp" , and a java Servlet in a file named "InfoServlet.java". The user's home directory is /home/jdoe.

  Write a java program that reads unspecified number

Write a java program that reads unspecified number of integers (the input 0 signifies the end of the input). Calculates and displays the sum and the average of the input value (not counting zero). The program also finds the maximum and minimum of ..

  Accepts a string as its parameter and returns an integer

Write a method in java named secondHalfLetters that accepts a string as its parameter and returns an integer representing how many of letters in the string come from the second half of the alphabet

  Xml assignment help please follow instructions in the

please follow instructions in the attached assignment instructions. ltbrgtplease follow instructions in the attached

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd