answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
stepladder [879]
1 year ago
10

"Suppose there is a class Alarm. Alarm has two class variables, code which contains a String value representing the code that de

activates the alarm, and armed which contains a boolean describing whether or not the alarm is activated. Alarm has a function disarm that changes the value of armed to False if the user gives a parameter containing the string that represents the alarm's code. Call the disarm function on the Alarm object myAlarm and give it the code "93478"."
Computers and Technology
1 answer:
Marrrta [24]1 year ago
7 0

Answer:

Following are the program in the Python programming Language.

#define class

class Alarm:

 #define constructor

 def __init__(self,code,armed = False):

   self.code = code #initialize value

   self.armed = armed #initialize value

 #define function

 def changeCode(self,currentCode,newCode):

   #set if conditional statement

   if currentCode == self.code:

     #initialize value if the condition is true

     self.code = newCode

     #return value

     return newCode

#set object of the class and pass value in constructor  

myAlarm=Alarm("93478")

#call and print the function

myAlarm.changeCode("93478","1234")

print(myAlarm.code)

<u>Output</u>:

1234

Explanation:

Here, we define a class "Alarm" and inside the class.

  • Define a constructor and pass arguments in its parameter "code" ,"armed" and assign a boolean value in the variable "armed" to False.
  • Then, initialize the variables inside it.
  • Define the function name "changeCode()" and pass arguments in its parentheses "currentCode" and "newCode" inside it, we set if condition and check whether the "currentCode" is equal to the code the initialize into code the value of "newCode".

Finally, we set an object of the class and pass value in its parentheses for the constructor and then, we call the function and pass values in its parameter then, we print the code.

You might be interested in
Consider a disk that rotates at 3600 rpm. The seek time to move the head between adjacent tracks is 2 ms. There are 32 sectors p
jasenka [17]

Answer:

19.71 ms

Explanation:

The disk rotates at 3600 rpm, hence the time for one revolution = 60 / 3600 rpm = 16.67 ms.

Hence time to read or write on a sector = time for one revolution / number of sectors per track = 16.67 ms / 32 sectors = 0.52 ms

Head movement time from track 8 to track  9 = seek time = 2 ms

rotation time to head up sector 1 on track 8 to sector 1 on track 9 = 16.67 * 31/32 = 16.15 ms

The total time = sector read time +head movement time + rotational delay + sector write time = 0.52 ms + 2 ms + 16.15 ms + 0.52 ms = 19.19 ms

3 0
2 years ago
c++ You are given an array A representing heights of students. All the students are asked to stand in rows. The students arrive
Lilit [14]

The below code will help you to solve the given problem and you can execute and cross verify with sample input and output.

#include<stdio.h>

#include<string.h>

 int* uniqueValue(int input1,int input2[])

 {

   int left, current;

   static int arr[4] = {0};

   int i      = 0;

     for(i=0;i<input1;i++)

      {

         current = input2[i];

         left    = 0;

         if(current > 0)

         left    = arr[(current-1)];

      if(left == 0 && arr[current] == 0)

       {

       arr[current] = input1-current;

       }

       else

   {

       for(int j=(i+1);j<input1;j++)

       {

           if(arr[j] == 0)

           {

               left = arr[(j-1)];

               arr[j] = left - 1;

           }

       }

   }

}

return arr;

}

4 0
2 years ago
Write a method for the Customer class that that will return a string representing a bill notice when passed a double value repre
Nesterboy [21]

Answer:

Following are the method definition to this question:

public String notice_bill(double amount) //defining method

{

return this.name+", account number "+this.currAccNum+", please pay $"+amt;  //return value.

}

Explanation:

In the given question some information is missing, that is example So, method definition to this question can be described as follows:

  • In the above method definition a string method "notice_bill" is declared, which accepts a double value in its parameter, that is "amount".
  • Inside the method, this keyword is used, that hold values and return its value as a message.  
5 0
2 years ago
Which phrase best describes a scenario in Excel 2016?
Airida [17]

Answer:

what are the phrases?

Explanation:

6 0
2 years ago
5.6 Look carefully at how messages and mailboxes are represented in the email system that you use. Model the object classes that
Annette [7]

Answer:

See explaination for the details of the answer.

Explanation:

A class is a structured diagram that describes the structure of the system.

It consists of class name, attributes, methods and responsibilities.

A mailbox and an email message has some certain attributes such as, compose, reply, draft, inbox, etc.

See attachment for the Model object classes that might be used in the system implementation to represent a mailbox and an email message.

5 0
2 years ago
Other questions:
  • Frequency of failure and network recovery time after a failure are measures of the _______ of a network.
    11·1 answer
  • When a switch configuration includes a user-defined error threshold on a per-port basis, to which switching method will the swit
    13·1 answer
  • Static packet filtering firewalls are limited to ________. inspecting packets for which there are good application proxy filteri
    8·1 answer
  • JAVAThe method longestStreak is intended to determine the longest substring of consecutive identical characters in the parameter
    7·1 answer
  • Apart from the challenges of heterogeneity, business and social change and trust and security, identify other problems and chall
    9·1 answer
  • Consider a single-platter disk with the following parameters: rotation speed: 7200 rpm; number of tracks on one side ofplatter:
    10·1 answer
  • Wendy is an attacker who recently gained access to a vulnerable web server running Microsoft Windows. What command can she use t
    9·1 answer
  • Describe copyright statute, disclaimers, and filing procedures.
    5·1 answer
  • Which group contains the command to manually conduct a spell check ?
    9·1 answer
  • The hostel in which you plan to spend the night tonight offers very interesting rates, as long as you do not arrive too late. Ho
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!