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

Place your order
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more
error: Content is protected !!