Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

agile coding Question 2. (3+(1.25 +1.75) =6 marks) In Java, Abstract Data Types can be used to store collections of data. Abstract Data Types include

agile coding
image text in transcribed
Question 2. (3+(1.25 +1.75) =6 marks) In Java, Abstract Data Types can be used to store collections of data. Abstract Data Types include Lists. A concrete java class that implements a List is an ArrayList. Arrays can also be used to create a group of like objects into an Array data structure. a) Assume you have a collection of data objects representing train services, including their departure station, arrival station and scheduled day and time for departure. Show the java code that would create either an ArrayList or an Array to create a collection of 'TrainService' objects in the reference variable allTrain Services. The code should declare a reference variable named allTrainServices and allocate memory for storing references of up to 150 services. [3 marks] b) Each TrainService object will have a serviceNumber (int), serviceDay (String) and departure Time (double) and two (2) associated Station objects that contains all the data for the departure and arrival train stations. These Station objects will be referred to in each TrainService object as departure Station and arrivalStation. i. List the class attributes for the TrainService class (1.25 marks) and ii. Write the 4 lines of Java code that would declare these attributes in the TrainService.java file. [1.75 marks]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

How to reverse a Armstrong number by using double linked list ?

Answered: 1 week ago

Question

1. Diagnose and solve a transfer of training problem.

Answered: 1 week ago