Question: Eclipse Java Programming. All given .java code is listed below aslong as a .txt file given to do problem. ArrayStack.java: public class ArrayStack implements StackADT

Eclipse Java Programming. All given .java code is listed below aslong as a .txt file given to do problem.

Eclipse Java Programming. All given .java code is listed below aslong asa .txt file given to do problem. ArrayStack.java: public class ArrayStack implementsStackADT { private int capacity; private int top; private T[ ] stack;@SuppressWarnings("unchecked") public ArrayStack ( ) // POST: empty stack of capacity 10

ArrayStack.java:

public class ArrayStack implements StackADT {

private int capacity; private int top; private T[ ] stack; @SuppressWarnings("unchecked") public ArrayStack ( ) // POST: empty stack of capacity 10 { capacity = 10; top = 0; stack = (T [ ]) new Object [capacity]; } @SuppressWarnings("unchecked") // PRE: cap > 0 public ArrayStack (int cap) // POST: empty stack of capacity cap { capacity = cap; top = 0; stack = (T [ ]) (new Object [capacity]); } public void push (T element) // POST: element pushed onto stack { if (top == capacity) resize(); stack[top] = element; top++; } @SuppressWarnings("unchecked") private void resize() // POST: array is doubled { T [ ] temp = (T[ ]) new Object [capacity*2]; for (int k = 0; k

}

EmptyCollectionException.java

@SuppressWarnings ("serial") public class EmptyCollectionException extends RuntimeException { public EmptyCollectionException ( ) { super ("The collection is empty."); } }

Lot.txt

A EARLYBIRD 6:30 A WORKER 7:00 A CEO 7:15 A CLERK 7:30 A MANAGER 8:00 A VP 9:00 D CLERK 9:30 A SHOPPER 10:15 D CEO 10:00 D EARLYBIRD 10:30 D WORKER 11:00 A JANITOR 11:00 D MANAGER 11:30 D LOSTMYCAR 11:35 A STUDENT 11:35 A HOUSEWIFE 12:45 A RETIREE 13:30 A SALESMAN 13:45 D STUDENT 15:30 A CONTRACTOR 16:00 D SHOPPER 16:30 D JANITOR 19:30 D HOUSEWIFE 20:00 D RETIREE 21:15 D CONTRACTOR 23:00 D CARTHIEF 23:50 

ParkTime.java//Time.java

import java.util.Scanner;

public class Time { private int hour; // hour (0 - 23) private int minute; // minute (0 - 59) public Time ( ) // POST: empty Time object { } public Time (int h, int m) // PRE: 0

}

Part II: (80 pts) This program will compute income from a small parking lot. It uses a stack to hold data in LIFO order. Use classes ArrayStack and EmptyCollectionException developed in lecture, available on First Class. Acompany rents a 5-car alley for parking. The alley is so narrow that the only egress is at the top, forcing vehicles to be removed one at a time in order to retrieve an internal one Vehicles are temporarily parked on the street until they can be returned to the alley. Cars do not need to returned to the alley in any particular order. alley is a stack street metered parking One day's data set is available in file lot.txt on First Class. Arrival/Departure Code String ("A" or "D") License String (ex. "BOSS") Time Time (ex. 10:30 or 21:45) Read in the lines of the data files and recreate the movement of cars in and out of the parking lot. Vehicles are charged $4.50 per hour for the duration of their stay. If a person arrives and claims to have a car but the car is not found, catch the EmptyCollectionException and note this in your output. Cars are then just returned to the parking lot. Partial hours are rounded up. Cars parked temporarily on the street pay a $0.25 meter fee

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!