Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

In java Using the following code:

import java.util.*;

public class Test { public static void main(String[] args)

{ /* PART 1 - Object and Classes */

System.out.println("Part 1: Object and Classes\n");

// Create scanner object Scanner input = new Scanner(System.in);

// Prompt user to enter new airport name System.out.println("Enter airport name: ");

// Create airport object (with its name ap) using inputted name Airport ap = new Airport(input.nextLine());

// Prompt user to enter first gate's name System.out.println("Enter first gate's name: ");

// Store inputted name as a String variable called n1 String n1 = input.nextLine();

// TODO: Prompt user to enter first gate's length in meters

// TODO: Store inputted length as an int variable called l1

// TODO: Create first gate object (with its name g1) using n1 and l1

// TODO: Prompt user to enter second gate's name

// Store inputted name as a String variable called n2 String n2 = input.next();

// TODO: Prompt user to enter second gate's length in meters

// TODO: Store inputted length as an int variable called l2

// TODO: Create second gate object (with its name g2) using n2 and l2

// TODO: Prints out g1's name

// TODO: Prints out g2's name

// TODO: Prompt user to enter new name for g1

// TODO: Store inputted name as a new String variable named newG1 String newG1 = input.next();

// TODO: Set inputted name as g1's new name

// TODO: Prints out g1's new name

// TODO: Adds the two gate objects into airport

// HINT: Call addGate method with reference to ap

/* PART 2 - Array, For Loops and Math Operation */

System.out.println("\nPart 2: Array, For Loops and Math Operations\n");

// Prompt user to enter a size of array System.out.println("Enter desired size of array: ");

// TODO: Store input as an int variable named size

// TODO: Creates an integer 1D array (named nums) with size

// TODO: Prompt user to enter 5 integers

// TODO: Store 5 inputted integers into the nums array

// HINT: For loop // Make a new integer variable called sum, assign 0 as its value int sum = 0;

// TODO: Calculates the sum by adding all numbers in the nums array

// HINT: For loop // Prints out sum's value System.out.println("The sum of all numbers in array is: " + sum); } }

 

Define all of the classes within your FinalsReview
Class #1: Airport.java
Class #2: Gate.java
TestClass: Test.java (Only modify this class)
Airport Class
public class Airport {
private String name:
private int count;
private Gate [] listofGates = new
Gate [10];
}
public Airport () {
name = "N/A";
}
public Airport (String newName) {
name = new Name
}
public String getName() {
return this.name;
}
public void setName(String newName) {
this.name = new Name
}
public void addGate (Gate newGate) {
int size= listofGates.length;
}
if (count == size) {
return;
}
for (int i = 0; i < size; i++)
if (listofGates [i]
listofGates[i]
}
count++;
break;
== null) {
newGateż
=
Gate class:
public class Gate {
private String name;
private int length;
{
{
public Gate () {
}
}
newLength) {
public Gate (String newName, int
}
}
name = "N/A";
length 0;
public String getName() {
return this.name:
}
name = newName;
length
public void setName(String newName)
}
= newLength:
}
public int getLength) {
return this.length;
this.name newName
public void setLength(int newLength)
this length newLength;
expand button
Transcribed Image Text:Define all of the classes within your FinalsReview Class #1: Airport.java Class #2: Gate.java TestClass: Test.java (Only modify this class) Airport Class public class Airport { private String name: private int count; private Gate [] listofGates = new Gate [10]; } public Airport () { name = "N/A"; } public Airport (String newName) { name = new Name } public String getName() { return this.name; } public void setName(String newName) { this.name = new Name } public void addGate (Gate newGate) { int size= listofGates.length; } if (count == size) { return; } for (int i = 0; i < size; i++) if (listofGates [i] listofGates[i] } count++; break; == null) { newGateż = Gate class: public class Gate { private String name; private int length; { { public Gate () { } } newLength) { public Gate (String newName, int } } name = "N/A"; length 0; public String getName() { return this.name: } name = newName; length public void setName(String newName) } = newLength: } public int getLength) { return this.length; this.name newName public void setLength(int newLength) this length newLength;
Class #1 - Airport class
instance name
instance Gate array of size 10
Default constructor
●
●
●
Class #2 - Gate class
Constructor with 1 parameter
A getter and a setter for instance name
addGate method
●
●
●
●
Class #3 Test class
●
●
instance name, length
Default constructor
Constructor with 1 parameter
2 sets of getter/setter
●
// TODO: Prints out g1's name
Part 1: Object and Classes, utilizing Airport and Gate
class
Not fully implemented - modifications
needed
Put appropriate commands/line of
code below TODO comments
Example:
Creating 1 airport and 2 gates with inputted
name and length
Changing name of gates
Adding 2 gates into. airport list
●
Part 2: Array, For Loop and Math Operation
Creating new array based on user-defined size
Adds values into array provided by user
Part 1: Object and Classes
Enter airport name:
San Francisco
Enter first gate's name:
G97
Enter first gate's length in meters:
30
Enter second gate's name:
G98
Enter second gate's length in
30
Gate 1's name is: 697
Gate 2's name is: 698
Enter Gate 1's new name:
G99
Gate 1's name is now: 699
rs:
Iterating through the array and calculate the
sum of all values in the array
These are the final
output !
Part 2: Array, For Loops and Math Operations
Enter desired size of array:
10
Enter 5 integers to store into array:
The sum of all numbers in array is: 15
Process finished with exit code 0
expand button
Transcribed Image Text:Class #1 - Airport class instance name instance Gate array of size 10 Default constructor ● ● ● Class #2 - Gate class Constructor with 1 parameter A getter and a setter for instance name addGate method ● ● ● ● Class #3 Test class ● ● instance name, length Default constructor Constructor with 1 parameter 2 sets of getter/setter ● // TODO: Prints out g1's name Part 1: Object and Classes, utilizing Airport and Gate class Not fully implemented - modifications needed Put appropriate commands/line of code below TODO comments Example: Creating 1 airport and 2 gates with inputted name and length Changing name of gates Adding 2 gates into. airport list ● Part 2: Array, For Loop and Math Operation Creating new array based on user-defined size Adds values into array provided by user Part 1: Object and Classes Enter airport name: San Francisco Enter first gate's name: G97 Enter first gate's length in meters: 30 Enter second gate's name: G98 Enter second gate's length in 30 Gate 1's name is: 697 Gate 2's name is: 698 Enter Gate 1's new name: G99 Gate 1's name is now: 699 rs: Iterating through the array and calculate the sum of all values in the array These are the final output ! Part 2: Array, For Loops and Math Operations Enter desired size of array: 10 Enter 5 integers to store into array: The sum of all numbers in array is: 15 Process finished with exit code 0
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education