Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

piCombination.java - Sublime Text (UNREGISTERED) File Edit Selection Find View Goto Tools Project Preferences Help combinationjava 'Q3Arfa xDoorl ock.java Ticket java 1 public class Combination

image text in transcribedimage text in transcribed

piCombination.java - Sublime Text (UNREGISTERED) File Edit Selection Find View Goto Tools Project Preferences Help combinationjava 'Q3Arfa xDoorl ock.java Ticket java 1 public class Combination int first; int second; int third; public Combination( int first, int second, int third ) 1 4. this.first first; this.second second this.third third 10 public boolean equals( Combination other) if (othernull) 12 13 14. 15 16 17 18 19 20 21 return false; else if (other.first first&& other.second second && other.third third) return true; else return false; public String toString() return first +":"second :" third 23 24 Line 5, Column 51 Soaces: 4 3:14 PM Type here to search 1/22/2019 D Lab 2 IT111 21 ABIC] Introc Fullscreen Pageflip Layout v- x + www.site.uottawa.ca/~gy/C X > Prime Video N ot securewww.site.uottawa.ca/ gy Courses IT 1 121/ Q -) c Not secure www site uottawa.ca/gv Courses IT 1121/ Q public lass DoorLack i Conctant public satic final int HAX NUMBLROF ATTLMPTS 3 Create animplementation for the class DoorLock described below. 1. declare an integer constant, called MAX NUMBER OF ATTEMPTS, that you will initialize to the value 3; 2. instance variables. The class DoorLock must havc the neccssary instance variables to Instanco variables prtvato Lonhination carbination private hoolean open private int nuberofnttenpts; i. storc an object of thc class Combination i. lo represeril the properly of beirg opeed or closed ill, to represent its activation state (the door lock is activated or deactivated. and iv. to couint the number of unsuccessful attempts at openin the door; on-Lructur, public DvorLuck Conbinatin conbinstion Your code here Accoss ricthads public bcolean 1s0pcn) f 3. he cless has a single cons Lr uclo, DoorLock( Combination combination) which initielices lhis inslance wilh a return apen; combination.When a door lock is first created, the door lck is closed. Also, when the object is first created, it is activated and the number of failed attempts at opening it should be zero; 4, implernent the instance melhod public boolean IsOpen() that returns true if this door lock is currently opened 5, implernent the instance melhod public boolean isActivated that returns true if this door lock is currently 6. implement the instance method public void activate(Combination c) that scts the instance variable "activated" 7. finally, implement the instance method public boolean open( Combination combination)such that and false otherwise; // Nu Lite U'al "unter DFALl_enpLs 1, Lurc.ared to NAX NUMBER OF ATTEMPTS unly when its value tes been incrented, Also, nmbe OfAttenpts should be set to zero when activated and false otherwise; // ctivated is false. Proolens re1ated to the contined action of these two variables have caued problens for e students o rue il Lhe paraelr cequals" lo lhe combinalion of Lhis object; public bcolean cpen Conbination comtination 1 Put your code hare, then rerave the lina balcw return trua; i. an attempt is made at opening this door lack only if this door lock is activated i. it the parameter combination "equals to the combination of this door lock, set the state of the door to be open, and the number of failed attempts should be reset to zero public void activate( rosn1nation) ( Put your code her, then reave this coment iii. otherwise, lL.f the wrong Combination was supplied, the number of failed attempts should be incremented by one, iv. if the number of failcd attempts rcachcs MAX NUMBER OF ATTEMPTS, this door lock should bc 12:38 AM Type here to search 1/22/2019

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

Formal SQL Tuning For Oracle Databases Practical Efficiency Efficient Practice

Authors: Leonid Nossov ,Hanno Ernst ,Victor Chupis

1st Edition

3662570564, 978-3662570562

More Books

Students also viewed these Databases questions