Object Oriented Application Development week 3

Object Oriented Application Development week 3

In this assignment, you will be asked to demonstrate what you have learned in the Discussion Board in terms of vector, wrapper classes, conversion, and collection data structures by writing and implementing Java code within your application that demonstrates each of these concepts. Hint: These may be utilized in areas of storing items in the customer order so that you can allow the customer to order more than one sub or beverage. Refer to the sample prototype in Unit 1 for the various item lists you will use. Feel free to add more choices to each of these lists.

Deliverable

The following are the Unit 3 Individual Project deliverables:

  • Update the title page for the Design Document with the Project Name (Unit 3 IP) and date.
  • Add the following section header: Phase 3 Revised Application Screenshots.
  • Add screenshots of each distinct screen from your running application.
  • Name the document yourname_ITSD424_IP3.doc.
  • Submit the design document and the zipped Java project files for grading.

(Discussion Board Answer)

One – Vector Class and Methods

(for the creation and manipulation of queues and stacks)

Vectors are similar to Arrays, but Arrays are limited in size and is used where the number of elements handled is known, and Vectors are unlimited in size and used where the number of elements dealt with is not known (Tutorialpoints.com, 2017). As it stands, Vectors seem to have the advantage. Also its infinite capacity, it proves to be very powerful for use because it also contains useful methods such as:

  • void insertElementAt(Object obj, int index)
  • Object ElementAt(int index)
  • void copyInto(Object[] anArray
  • int capacity()
  • void addElement(Object obj)

Code Sample:

/** Below is code that demonstrates how vectors are created, return the size and capacity of the vector, and adding new elements to a vector. */ import java.utils.*; public class VectorDemo { public static void main(String arg[]) { Vector vec = new Vector(1 , 1); System.out.println(“Initial size: ” +vec.size()); System.out.println(“Initial capacity: ” +vec.capacity()); vec.adElement(new Interger(12)); vec.adElement(new Interger(23)); vec.adElement(new Interger(34)); System.out.println(“Capacity after additions: ” +vec.capacity()); } }

Two – Wrapper Classes

(For primitives)

Objects are filed in a collection, but primitives such as ints and floats are not. Arrays, on the other hand, can hold primitives. Primitives can be placed in a collection by using a wrapper class to wrap it into an object. In short, primitives can be converted into objects and vice versa using wrapper classes (Oracle.com, 2017).

Code Sample:

/** Below is convertion code that changes ints to Integers, integers back to ints, doubles to Doubles, and Doubles back to doubles. */ //auto-unbox from Double to double double d = doubleObj; //auto boxing from double to Double Double doubleObj = 55.66 //auto-unbox from integer to int int i = intObj; //auto box from int to integer Integer intObj = 5566;

Three – Conversion Methods

(Converting Multiple Strings)

In Java Applications, Strings are highly advised to be used as Java Strings provide a multitude of methods to perform on strings (Oracle.com, 2017). Some String Methods are:

  • For String Concatenation:
    • String concat(String str);
  • For returning a substring:
    • String substring(int beginIndex);
    • Returns string length:
      • int length();
      • Finds a char at a particular index:
        • char charAt(int index);
        • Code Sample:

          /** Below is a Demonstration of how to manipulate strings inside of Java. */ public class Test { public static void main(String args[]} String s= “String concept”; char result = s.charAt(8); System.out.pring(result); } }

          "You need a similar assignment done from scratch? Our qualified writers will help you with a guaranteed AI-free & plagiarism-free A+ quality paper, Confidentiality, Timely delivery & Livechat/phone Support.


          Discount Code: CIPD30



          Click ORDER NOW..

          order custom paper