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

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

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