Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Help with Java Code

Name: Anonymous 2012-10-04 14:50

Ok, managed to get straight into 3rd year at University studying Computing after very little Java, so im struggling!

Please help!! Question/what I have done so far is as follows.

In this project you will get to be developer of a parameterized class, and become a user of
that class. To start with, here are method specifications for the parameterized class,
Sequence, with E the type parameter:

public class Sequence<E> {
   
    protected E[] data;
    protected int size;
   
   
    /**
    * Initialises this Sequence object to be empty, with an initial
    * capacity of ten elements.
    */
    public Sequence() {
       
        E[] data = (E[]) new Object[10];
        int size = 0;
       
       
    }
    /**
    * Initialises this Sequence object to be empty, with a specified
    * initial capacity.
    *
    * @param capacity - the initial capacity of this Sequence object.
    *
    * @throws IllegalArgumentException - if capacity is non-positive
    */
    public Sequence (int capacity){
        capacity = 0;
        throw new IllegalArgumentException();
    }
    /**
    * Returns the number of elements in this Sequence object.
    *
    * @return the number of elements in this Sequence object.
    */
    public int size (){
        return  0;
    }
    /**
    * Appends a specified element to this Sequence object.
    *
    * @param element - the element to be inserted at the end of this
    * Sequence object.
    */
    public void append (E element) {
       
    }
    /**
    * Returns the element at a specified index in this Sequence object.
    * The worstTime(n) is constant, where n is the number of elements in
    * this Sequence object.
    *
    * @param k - the index of the element returned.
    * *
* @return the element at index k in this Sequence object.
*
* @throws IndexOutOfBoundsException - if k is either negative or
* greater than or equal to the number of elements in this
* Sequence object.
*/
public E get (int k){ //Week 3 Laboratory – COMP09044 Page 2
   
    return null;
}
/**
* Changes the element at a specified index in this Sequence object.
* The worstTime(n) is constant, where n is the number of elements in
* this Sequence object.
*
* @param k - the index of the element required.
* @param newElement - the element to replace the element at index k
* in this Sequence object.
*
* @throws IndexOutOfBoundsException - if k is either negative or
* greater than or equal to the number of elements in this
* Sequence object.
*/
public void set (int k, E newElement){

}

}

Part 1: Create unit tests based on the method specifications and stubs.
Part 2: Define the methods in the Sequence class.
Hint: use the following fields:
protected E[] data;
protected int size; // The number of elements in the Sequence, not
// the capacity of the data array.
Note 1: for the append method, if the data array is currently full, its capacity must be
increased before the element can be appended. See Programming Exercise 2.10 to see how
to accomplish the expansion.
Note 2: for methods that may throw an exception, do not include catch blocks. Instead, the
exception will be propagated, so the handling can be customised for the application.
Part 3: Test the method definitions in your Sequence class.

Name: Anonymous 2012-10-04 14:53

What's the question?
Also, no, I won't help, apart from to say: Read SICP.

Name: Anonymous 2012-10-04 14:56

I stopped reading after `Java'.

Name: Anonymous 2012-10-04 14:57

Question is at the bottom of the code. I am trying to cram in roughly 2 years worth of University level Java is quickly as I can. However I need a bit of help with code as it's easier to learn that way.

Currently working my way through 'Data Structures and the Java Collections Framework' by William J Collins (recommended reading)

Name: Anonymous 2012-10-04 15:01

`University level Java'

Name: Anonymous 2012-10-04 15:02

2 years of uni-level java isn't much. I didn't learn shit in two years except how awful the language truly is. My third-year project is consequently in Scheme.

Name: Anonymous 2012-10-04 15:08

Yeah, I don't like it much either but sadly it comes with the degree. I will hopefully catch up with enough studying but I thought there would be some kind, java wizard who would give me a help.

Name: Anonymous 2012-10-04 15:54

Did you not do first and second year of university?

Name: Anonymous 2012-10-04 16:15

Nope, I didn't. Got straight into 3rd year through a college program. We spent about 3 hours in total on java in the time that I was there.

Name: Anonymous 2012-10-04 17:21

Fuck off [b][i]ENTERPRISE LOVING KIKE[/i][/b]

Name: Anonymous 2012-10-04 17:30

>>10
typical goyish retard

Name: Anonymous 2012-10-04 20:22

>>11
Shalom!

Name: Anonymous 2012-10-04 21:59

>>12
WHAT IS THIS SHIT?
WHY THIS GUY KEEP SAYIN SHALOM?
FUCK U ALL!

Name: Anonymous 2012-10-04 22:48

>>13
∫h∆loµ!

Don't change these.
Name: Email:
Entire Thread Thread List