Question

A pmc has contacted you to help write code to control the security checkpoints for their...

A pmc has contacted you to help write code to control the security checkpoints for their company. You must create a checkpoint class with hidden attributes (Authorized, guest, Unauthorized), two constructors (a default that sets all access level to false and an overloaded that sets authorized and unauthorized to false and guest to true for testing purposes) and a method that changes the access levell to the next in the sequence(authorized - guest - unauthorized)

In java

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. Thanks

// CheckPoint.java

public class CheckPoint {

      private boolean authorized;

      private boolean guest;

      private boolean unauthorized;

      // default constructor that sets all levels to false

      public CheckPoint() {

            authorized = false;

            guest = false;

            unauthorized = false;

      }

      // overloaded constructor that sets authorized and unauthorized to false and

      // guest to true/false (depends upon the given boolean value)

      public CheckPoint(boolean guest) {

            authorized = false;

            unauthorized = false;

            // if you want to make guest true always, change the below statement to

            // this.guest=true

            this.guest = guest;

      }

      // method to advance the access level to next in the sequence (authorized -

      // guest - unauthorized)

      public void changeToNextLevel() {

            // if the user is authorized, changing to guest

            if (authorized) {

                  authorized = false;

                  guest = true;

                  unauthorized = false;

            }

            // if the user is guest, changing to unauthorized

            else if (guest) {

                  authorized = false;

                  guest = false;

                  unauthorized = true;

            }

            // if the user is uauthorized or if all three values are false, changing

            // to authorized

            else {

                  authorized = true;

                  guest = false;

                  unauthorized = false;

            }

      }

      // getter methods for access levels

      public boolean isAuthorized() {

            return authorized;

      }

      public boolean isGuest() {

            return guest;

      }

      public boolean isUnauthorized() {

            return unauthorized;

      }

}

Add a comment
Know the answer?
Add Answer to:
A pmc has contacted you to help write code to control the security checkpoints for their...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • using java : Kenmore has contacted you to help write code to control their new line...

    using java : Kenmore has contacted you to help write code to control their new line of home appliances. Write the “Refrigerator” class that has tracks the temperature of the refrigerator and the amount of water remaining in the water dispenser (max is 100 ounces). Kenmore also needs you to create a constructor and methods to increase or decrease the temperature along with dispensing water (8 ounces at a time) and refilling the water tank from a connected water hose....

  • [CODE] Write a class encapsulating the concept of a house, assuming a house has the following...

    [CODE] Write a class encapsulating the concept of a house, assuming a house has the following attributes: value (in dollars), a city location, and number of bedrooms. Your class name should be “House” and your code should be in a file called “House.java”. You will need to create this file. In this class, include: Private instance variables for the previously-mentioned attributes A default constructor An overloaded constructor Accessor and mutator methods (i.e., get and set methods) The toString method The...

  • Language = C++ How to complete this code? C++ Objects, Structs and Linked Lists. Program Design:...

    Language = C++ How to complete this code? C++ Objects, Structs and Linked Lists. Program Design: You will create a class and then use the provided test program to make sure it works. This means that your class and methods must match the names used in the test program. Also, you need to break your class implementation into multiple files. You should have a car.h that defines the car class, a list.h, and a list.cpp. The link is a struct...

  • no buffered reader. no try catch statements. java code please. And using this super class: Medialtemjava...

    no buffered reader. no try catch statements. java code please. And using this super class: Medialtemjava a Create the "middle" of the diagram, the DVD and ForeignDVD classes as below: The DVD class will have the following attributes and behaviors: Attributes (in addition to those inherited from Medialtem): • director:String • rating: String • runtime: int (this will represent the number of minutes) Behaviors (methods) • constructors (at least 3): the default, the "overloaded" as we know it, passing in...

  • EMULATE A PROCESS CONTROL BLOCK In this assignment you will use Java, Python or C++ to...

    EMULATE A PROCESS CONTROL BLOCK In this assignment you will use Java, Python or C++ to create a process control block. All objects described aren’t provided, you will create them. You can divide up this code into separate files or put all code in one file. Proper documentation is essential, if there are no comments 5% of the total grade will be deducted. The process control block object PCB should have the following fields: ID: a unique ID for this...

  • When answering this question, can you please specify what you name your files? Thank you! Write a...

    When answering this question, can you please specify what you name your files? Thank you! Write a Java application, and an additional class to represent some real-world entity. Keep in mind that a class is a model in code of something real or imagined, which has attributes (member variables) and behaviors (member methods). The class will: a. Create a total of 5 member variables for the class, selecting the appropriate data types for each field. For example, a class to...

  • Java Netbeans code Option 1: Authentication System For security-minded professionals, it is important that only the...

    Java Netbeans code Option 1: Authentication System For security-minded professionals, it is important that only the appropriate people gain access to data in a computer system. This is called authentication. Once users gain entry, it is also important that they only see data related to their role in a computer system. This is called authorization. For the zoo, you will develop an authentication system that manages both authentication and authorization. You have been given a credentials file that contains credential...

  • fisrt one is bicycle.java second code is bicycleapp.java can anyone help this??? please save my life...

    fisrt one is bicycle.java second code is bicycleapp.java can anyone help this??? please save my life Before you begin, DOWNLOAD the files “Lab8_Bicycle.java” and “Lab8_BicycleApp.java” from Canvas to your network drive (not the local hard drive or desktop). Once you have the files saved, RENAME THE FILES Bicycle.java and BicycleApp.java then open each file. 1) Look at the Bicycle class. Two of the many data properties we could use to define a bike are its color and the gear it...

  • Create a UML diagram to help design the class described in exercise 3 below. Do this...

    Create a UML diagram to help design the class described in exercise 3 below. Do this exercise before you attempt to code the solution. Think about what instance variables will be required to describe a Baby class object; should they be private or public? Determine what class methods are required; should they be private or public? 3. Write Java code for a Baby class. A Baby has a name of type String and an age of type integer. Supply two...

  • code in java please:) Part I Various public transporation can be described as follows: A PublicTransportation...

    code in java please:) Part I Various public transporation can be described as follows: A PublicTransportation class with the following: ticket price (double type) and mumber of stops (int type). A CityBus is a PublicTransportation that in addition has the following: an route number (long type), an begin operation year (int type), a line name (String type), and driver(smame (String type) -A Tram is a CityBus that in addition has the following: maximum speed (int type), which indicates the maximum...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT