Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Level one Jack.java Coding here: public class Jack { private String buildingCode; private String jackType; private int roomNumber; private int jackNumber; // Default constructor that

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Level one

Jack.java Coding here:

public class Jack { private String buildingCode; private String jackType; private int roomNumber; private int jackNumber; // Default constructor that sets the attributes public Jack () { buildingCode = "???"; jackType = ""; roomNumber = 0; jackNumber = 0; } // Parameterized constructor that accepts values to set buildingCode, roomNumber, and jackNumber and also sets jackType to "ENET" public Jack ( String _buildingCode, int _roomNumber, int _jackNumber ) { buildingCode = _buildingCode; roomNumber = _roomNumber; jackNumber = _jackNumber; jackType = "ENET"; jackType = "PH"; jackType = "VID"; } //Accessors for getBuildingCode public String getBuildingCode() { return buildingCode; } //Accessors for getJackType public String getJackType() { return jackType; } //Accessors for getRoomNumber public int getRoomNumber() { return roomNumber; } //Accessors for getJackNumber public int getJackNumber() { return jackNumber; } // Mutators for setBuildingCode public void setBuildingCode ( String _buildingCode ) { buildingCode = _buildingCode; } // Mutators for setJackType public void setJackType ( String _jackType ) { jackType = _jackType; } // Mutators for setRoomNumber public void setRoomNumber ( int _roomNumber ) { roomNumber = _roomNumber; } // Mutators for setJackNumber public void setJackNumber ( int _jackNumber ) { jackNumber = _jackNumber; } } // end of class

TestJack.java coding here:

import java.util.Scanner;

public class TestJack { // main method public static void main (String[] args) { // Scanner object Scanner scan = new Scanner(System.in); // Set the values String buildingCode; int roomNumber; int jackNumber; String jackType; // prompts the Building code System.out.print("Building code: "); buildingCode = scan.nextLine(); while(buildingCode.length() !=3) { System.out.println("The code must be 3 characters long"); System.out.print("Building code: "); buildingCode = scan.nextLine(); } // prompts the Room number System.out.print("Room Number: "); roomNumber = scan.nextInt(); while(roomNumber = 99999) { System.out.println("The room number must be in the range of 1 to 99999"); System.out.print("Room number: "); roomNumber = scan.nextInt(); } // prompts the Jack number System.out.print("Jack Number: "); jackNumber = scan.nextInt(); while(jackNumber = 24) { System.out.println("The jack number must be in the range of 1 to 24"); System.out.print("Jack number: "); jackNumber = scan.nextInt(); } // prompts the Jack type System.out.print("Jack type: "); jackType = scan.nextLine(); while(jackType.length() !=4 && jackType.length() !=3 && jackType.length() !=2) { System.out.println("The type must be 'ENET,' 'PH,' or 'VID'."); System.out.print("Jack type: "); jackType = scan.nextLine(); } // Calls class object to set jack1 Jack jack1 = new Jack( buildingCode, roomNumber, jackNumber ); // set the mutator and set jackType in the parameter jack1.setJackType( jackType ); //Print the result System.out.printf("%s-%s-%s is of type %s. ", jack1.getBuildingCode(), jack1.getRoomNumber(), jack1.getJackNumber(), jack1.getJackType() ); }//end of main } //end of class

Background Wall jacks at a company are fully identified by three data fields. The first identifies the building, the second identifies the room number, and the third identifies the jack number. For example ADM:234:01 describes a jack in the Administration building, room 234, and is the first jack in the wall. In addition to this information, jacks also have a type (Ethernet, phone, video), and sometimes a list of other information (e.g., phone #, IP addresses, occupant's name, etc.) Problemm Create a TestJack class containing a main) method that will instantiate an object from a Jack class. The requirements are broken down into 3 levels (see grading rubric, last two pages). It is recommended that the code be written in stages; i.e. complete level 1 before moving on to level 2, etc. Note that the 10-point bonus may be accomplished at any level Level 1 Requirements (78 points): Jack class: Has the following String attributes: o buildingCode o jackType Has the following integer attributes: o roomNumber o jackNumber Has mutators and accessors for all the above attributes . Has a default constructor that sets the attributes to the following values: o buildingCode "???" o jackType: ""' o roomNumber: 0 o jackNumber: 0 Has a parameterized constructor that accepts values to set buildingCode, roomNumber, and jackNumber and also sets jackType to"ENET" Background Wall jacks at a company are fully identified by three data fields. The first identifies the building, the second identifies the room number, and the third identifies the jack number. For example ADM:234:01 describes a jack in the Administration building, room 234, and is the first jack in the wall. In addition to this information, jacks also have a type (Ethernet, phone, video), and sometimes a list of other information (e.g., phone #, IP addresses, occupant's name, etc.) Problemm Create a TestJack class containing a main) method that will instantiate an object from a Jack class. The requirements are broken down into 3 levels (see grading rubric, last two pages). It is recommended that the code be written in stages; i.e. complete level 1 before moving on to level 2, etc. Note that the 10-point bonus may be accomplished at any level Level 1 Requirements (78 points): Jack class: Has the following String attributes: o buildingCode o jackType Has the following integer attributes: o roomNumber o jackNumber Has mutators and accessors for all the above attributes . Has a default constructor that sets the attributes to the following values: o buildingCode "???" o jackType: ""' o roomNumber: 0 o jackNumber: 0 Has a parameterized constructor that accepts values to set buildingCode, roomNumber, and jackNumber and also sets jackType to"ENET

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Guide To Client Server Databases

Authors: Joe Salemi

2nd Edition

1562763105, 978-1562763107

More Books

Students also viewed these Databases questions

Question

Briefly discuss the advantages and disadvantages of automation.

Answered: 1 week ago