Computer Science Homework Help

Computer Science Homework Help. Write the constructors and the methods that are necessary in class, Java computer science linked list homework

Please be sure you can deliver this task fully or otherwise please don’t take it.
We expect only high quality person to answer it fully.
Thank you

1.For the following questions – make sure you document them with comments in the code.
2.You must use classes Time1 and BusArrival – You can get those classes in the zip file attached OR here – https://gist.github.com/rootux/69b4909a090ceae2eb35
3.Also make sure that for each method you have a documentation in the header.
4.Make sure that the name of the methods would be exactly as written.
5.The result is 2 files – BusArrivalNode.java, BusStopList.java zipped inside a file.
6.Write as a comment on the API what is the time complexity and the place complexity of every method you wrote.

Question 1:

Class BusArrivalNode represents a single item in the linked list.

Class will include the two attributes:

1. BusArrival  _busArr

2. BusArrivalNode  _next

U must write the constructors and the methods that are necessary in class.

For this class you have to define three constructors:

1. public BusArrivalNode (BusArrival b)

Receive the bus arrival (an object from class BusArrival) next_ field will be set to null.

2. public BusArrivalNode (BusArrival b, BusArrivalNode n)

Gets the bus arrival (object from class BusArrival) and another item n from type BusArrivalNode. The constructor would init the attributes by the given parameters. _next field will point to n.

3. public BusArrivalNode (BusArrivalNode b)

Copy constructor. Notice you have to copy the information (next) itself and not a copy of the pointer. Which means  in this case aliasing is the right thing.

The methods in class BusArrivalNode are:

* public BusArrival getBusArr() – returns a copy of the bus arrival.

* public BusArrivalNode  getNext()- returns pointer to the next item. Notice that aliasing is not a mistake here either. You need to return the pointer next and not a copy of the pointer.

* public void aetBusArr (BusArrival b) – receives the bus arrival and update the arrival attribute in the vertex.

* public void setNext(BusArrivalNode  next) – receives a pointer and update the pointer attribute to the next item. Notice that aliasing is not a mistake here either. You need to update the information (next) itself and not a copy.

Question 2

Class BusStopList represent a bus stop.

Representation made by a linked list that keeps the bus arrivals to a certain stop. Class attributes are:

*BusArrivalNode  _head – head of bus arrival list.

U must write the BusStopList class definition. When the only method (instance variable) allowed is pointing to the start of the linked list! Clearly additional attributes can make  the methods more efficient! however, In BusArrivalList class you CANNOT define any other attribute.

Notice the list is not organized by the bus arrival time or by bus number or by any other criterion. Which means it could be that a bus that arrived at 10:00:00 will be before a bus that arrived at 9:00:00 at the list.

Class constructor is:

Default constructor which creates an empty list.

Class contains few methods:

*Boolean method add which recevies the bus number, number of passengers, bus arrive to stop time (as an object from class Time1 attached below) and adds it to the arrival list. If the adding will be successful = true, else=false. Adding fails when there is already a reaching time in the list that is the same.

*removeAllLine method that gets the bus number and deletes all the instances of the same bus number from the arrival list. If there is no such a number in the list method will do nothing.

*toString method returns representation of all the stored objects in the list that its head _head is Like a string of characters. Every bus arrival will be printed in a different line like:

“Bus no. 27 arrived at 09:24:10 with 13 passengers”

*getPopularLine method returns the most “popular” bus number. Which means the bus that arrived the most times to stop. If there’s more than one it will return one of them arbitrarily.

Make sure that the solution to this method will be effective( which means that it won’t go over the list more than one time).

* getAverageTime method returns an average of how long you need to wait for any bus to arrive. The average time representation is done in seconds. It can be assumed that there is at least two bus arrivals in the list. Notice the method should return a value from type long.

For example, if four buses arrived to stop at 9:30:00, 9:40:00, 10:00:00, 10:30:00 (bus number doesn’t matter) then the average time needed to wait is 20 minutes which is 20*60=1200 seconds. We will get the value 1200.

* totalPassengers method returns how many passengers arrived to stop today.

* maxPassengers method returns bus arrival that had the most passengers all day. It can be assumed that there is at least one arrival in the list.

You must write API for the 2 classes.

Notice all the possible errors in the methods.

Write as a comment on the API what is the time complexity and the place complexity of every method you wrote.

Keep the effectiveness of the methods you wrote! Full score will be given only for computational performance.

Constructor

BusStop()

Gets bus number, number of passengers, and The bus station arrival time. And adds it to the arrival list. If successfully added returns-true, else returns- false.

boolean add(int line, int pass, Time1 t)

Gets bus number and deletes all its instances from arrival list. If there no such number in the list, method will do nothing.  

void removeAllLine (int line)

Returns the most popular bus number (the one that arrived to stop the most times). If there is more than one it will return one arbitrarily.

int getPopularLine()

Returns an average of time needed to wait until any bus will arrive to stop. The average time representation is done in seconds.

long getAverageTime()

Returns number of passengers arrived to stop all day.

int totalPassengers()

Returns most passengers all day bus arrival.

BusArrival maxPassengers()

Returns a representation of all stored objects in a list. As string character.

String toString()


Please be sure you can deliver this task fully or otherwise please don’t take it.
We expect only high quality person to answer it fully.
Thank you

20160130184602time1_and_busarrival.zip

Computer Science Homework Help

 
"Our Prices Start at $11.99. As Our First Client, Use Coupon Code GET15 to claim 15% Discount This Month!!"