Complete ArrayCollection.java with following methods (Please complete code in java language):
public ArrayCollection();
public ArrayCollection(int size);
public boolean isEmpty();
public boolean isFull();
public int size(); // Return number of elements in the Collection.
public String toString();
public boolean add(T element); // Add an element into the Collection, return true if successful
public boolean remove(T target); // Remove the target from Collection, return true if successful
public boolean removeAll(T target); // Remove all occurrences of Target, return if successful
public void removeDuplicate(); // Remove duplicated element(s)
public boolean equals(ArrayCollection that); // Return true if this Collection is same as that Collection
public int count(T target); // Return the number of a given target in the Collection
public void merge(ArrayCollection that); // Merge this Collection with that Collection
public void enlarge(int size); //Increase this Collection with additional size elements
public void clear(); // Clear entire Collection
public boolean contains(T target); // Return true if the target is in the Collection
public int findIndex(T target); // Return index of the target
package Homework3;
public class ArrayCollection<T> {
protected static final int DEFAULT_CAPACITY = 100;
protected T[] elements;
protected int numberOfElements;
public ArrayCollection() {
this(DEFAULT_CAPACITY);
}
public ArrayCollection(int size) {
elements = (T[]) new Object[size];
numberOfElements = 0;
}
public boolean isEmpty() {
return numberOfElements == 0;
}
public boolean isFull() {
return numberOfElements == elements.length;
}
public int size() {
return numberOfElements;
}
public String toString() {
String collection = "";
for (int i = 0; i < numberOfElements; i++)
collection += elements[i] + "\n";
return collection;
}
public boolean add(T element) {
// Complete your code here
return true;
}
public boolean remove(T target) {
// Complete your code here
return true;
}
public boolean removeAll(T target) {
// Complete your code here
return true;
}
public void removeDuplicate() {
// Remove any duplicated elements
}
public boolean equals(ArrayCollection that) {
// Return true if ArrayCollection are identical.
boolean result = true;
// Complete your code here.
return result && this.size() == that.size();
}
public int count(T target) {
// Return count of target occurrences
int c = 0;
// Complete your code here
return c;
}
public void merge(ArrayCollection that) {
// Merge that ArrayCollection into this ArrayCollection
// Complete your code here
}
public void enlarge(int size) {
// Enlarge elements[] with additional size
// Complete your code here
}
public void clear() {
// Remove all elements in the collection
}
//Note: Different from textbook, this implementation has no 'found' and
'location' attributes.
// There is no find() method.
// There is a new methods findIndex().
public boolean contains(T target) {
// Return true if target is found
boolean found = false;
// Complete your code here
return found;
}
public int findIndex(T target) {
// Return index of target
int index = 0;
// Complete your code here
return index;
}
}
In: Computer Science
Organization Analysis " Thyssenkrupp Engineered Plastics "
Describe the quality assurance system and how it supports the corporate strategy.
In: Operations Management
In the fall 0f 2008 Countrywide Morgage Corporation announced that the private information for thousands of their customers, including social security numbers and loan numbers, had been compromised. Countrywide offered these customers a free 2-year subscription to a credit protection service. Should this action shield Countrywide from customer lawsuits? Could Countrywide do more? Should they? Given that it was a Countrywide employee who sold the data, does this change Countrywide's responsibilities toward the affected customers? Explain why or why not.
Answer in 3 paragraphs.
In: Computer Science
When 1.95 grams of Co(NO3)2 is dissolved in 0.750 L of 0.220 M KOH, what are the [Co 2+], [Co(OH)4 2-], and [OH-] if Kf of Co(OH)4 2- = 5.00x10^9?
In: Chemistry
In: Computer Science
In web programming what is the Client-Server model?
In: Computer Science
In: Mechanical Engineering
Your task is to build an Android application that satisfies the following requirements:
Has two activities: MainActivity that implements the main functionality of the application and AboutActivity that shows your full name as per college record and student id
The AboutActivity should be available through a menu
A back button should appear in the ActionBar of the AboutActivity that takes user back
to the MainActivity. It should be done through configuration!
MainActivity should implement the following functionality
o read the following input from the user: § number of hours worked
§ hourly rate
o calculate the pay using the following formula
§ if no of hours is less or equal than 40 then pay=no_of_hours*hourly_rate
§ else, pay=(no_of_hours-40)*hourly_rate*1.5 + 40*hourly_rate o calculate the tax using the following formula
§ tax=pay*0.18
o present following data to the user
§ pay
§ overtime pay § total pay
§ tax
In: Computer Science
An ink droplet with a mass of 1.2E-10 kg and a charge of
-1.6E-13 C is moving horizontally at 17 m/s. It then passes between
2 deflection plates. The horizontal length L of these plates is 1.5
cm. There is a uniform electric field of magnitude 1.4E6 N/C,
directed downward, between the plates. Everywhere else, the
electric field is zero.
a. Calculate the magnitude and direction of the droplet’s
acceleration between the plates. Ignore gravity.
b. Calculate the vertical deflection of the droplet when it reaches
the end of the plates.
In: Physics
Time Complexity: Build a table in Excel and record the time complexity taken by linear and binary search to look for an element with the following array sizes: 10, 50, 100, 200, 500, 700, 1000. Compare the performance of both algorithms highlighting the time complexity for both algorithms when run on small input size and when run on large input size.
To accomplish this, load a list with the file data and then create a program that selects at random X amount of elements from the original list (where X is a value that the user selects) and place them in an array, then select at random an element in the original list to search in the sampled array using both algorithms. Measure the time it takes for both algorithms on an array of a given input size.
In: Computer Science
What is a marketing channel system and value network can be used in Hypermarkets in GCC and in Oman a especially ?
In: Operations Management
Year Project A Project B 0 −$330 −$330 1 160 230 2 160 230 3 160 230 4 160 a. If the opportunity cost of capital is 12%, calculate NPV for both projects? (Do not round intermediate calculations. Round your answers to 2 decimal places.) Project NPV A $ 485.98 B 552.42 b. Which of these projects is worth pursuing if you have enough funds and they are not mutually exclusive? Project A Project B Both
In: Finance
Using the definition of Compact Set, prove that the union of two compact sets is compact. Use this result to show that the union of a finite collection of compact sets is compact. Is the union of any collection of compact sets compact?
In: Advanced Math
In: Math
Hello!
I need to present my xml file on the Windows form application I tried but it dosent work at button 2, I cann't show Xml_file. What is problem here please? have you any suggest or solution .
Here is my form code!
namespace MyFirstWindos { public partial class Form1 : Form { const string XML1 = "path"; const string XML2 = "Path"; const string ResultFile = "Path"; public Form1() { InitializeComponent(); } private void Run(object sender, EventArgs e)//run button { Compare_D_R d_R = new Compare_D_R(); d_R.compareD_R(); } private void Button3_Click(object sender, EventArgs e) { xmlGridView.ClearSelection(); } private void Button2_Click(object sender, EventArgs e)//show { if (showinput.Text != null) { string DefaultFile = "DefaultFile": string Alternative = "AlternativeFile"; string Result = "ResultFile"; if ( DefaultFile==showinput.Text) { DataSet ds = new DataSet(); xmlGridView.DataSource = ds.ReadXml(XML1); } if (Alternative == showinput.Text) { xmlGridView.DataSource = XML2; } if (Result == showinput.Text) { xmlGridView.DataSource = ResultFile; } else { MessageBox.Show("Invalid Input"); showinput.Text = string.Empty; showinput.Focus(); } } } private void TextBox1_TextChanged(object sender, EventArgs e) { } private void XmlGridView_CellContentClick(object sender,DataGridViewCellEventArgs e) { } private void Button4_Click(object sender, EventArgs e) { } } }
How can I play/show my xml_file on the grid view. I'm really new in winform so please try to understand my question. if you have a better Idea you are welcome it is a free desigen.
Thanks:
In: Computer Science