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]
2 years 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]2 years 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
Which statement correctly describes an adaptive score?
d1i1m1o1n [39]

B. An adaptive score changes in response to player actions in the game.

it <em>could</em> be D. if the context was in a musical score...like an orchestra...I think that's just there to be funny

5 0
2 years ago
Read 2 more answers
How do many corporations most likely manage the health and safety of their employees and the workplace?
s344n2d4d5 [400]

Answer:

The answer to this question is given below in the explanation section. However the correct option is only by following OSHA's rules and regulation.

Explanation:

Corporations most likely manage the health and safety of their emoployees and workplace only by following the OSHA's rules and regulations.

Because this is standard law that requires employers to provide their employees with working conditions that are free of known dangers. The OSH Act created the Occupational Safety and Health Administration (OSHA), which sets and enforces protective workplace safety and health standards for employees.

However, other options are not correct because these options do not cover the employees' protective workplace safety and health.

4 0
2 years ago
Darius needs to include contact information in an email that he is sending to a colleague . Which option should he choose from t
melamori03 [73]

The question is incomplete:

Darius needs to include contact information in an email that he is sending to a colleague . Which option should he choose from the ribbon?

-Attach File

-Attach Item

-Attach Policy

-Attach Signature

Answer:

-Attach Signature

Explanation:

-Attach file is an option that allows you to include any type of file that you need to send in the email.

-Attach Item  is an option that allows you to include an element from your email like a message in your inbox to the current one you are writing.

-Attach Policy is not an option.

-Attach Signature is an option that allows you to include a previously created signature with the contact information at the end of the message.

According to this, the answer is that the option that Darius should choose from the ribbon is attach signature because he needs to include contact information.

4 0
2 years ago
A Color class has three int color component instance variables: red, green, and blue. Write a toString method for this class. It
ELEN [110]

Answer:

public String toString() {

return "#(" + red + "," + green + "," + blue + ")";

}

Explanation:

The code:

public String toString() {

return "#(" + red + "," + green + "," + blue + ")";

}

Is a tostring java code, and it is so easy to write one, as compare to other programming languages

Writing a tostring method returns a strinb representation of an object in Java. Normally, the toString method returns the name of the object’s class plus its hash code.

This code creates a new colour object; then the result of its toString method is printed to the console.

Tostring method can be override. The default implementation of toString isn’t very useful in most situations. So, one can just override it.

8 0
2 years ago
Create a class named Poem that contains the following fields: title - the name of the poem (of type String) lines - the number o
denpristay [2]

Answer:

Couplet.java



public class Couplet extends Poem

{

private final static int LINES = 2;

public Couplet(String poemName)

{

super(poemName, LINES);

}

}

Haiku.java

public class Haiku extends Poem

{

private static int LINES = 3;

public Haiku(String poemName)

{

super(poemName, LINES);

}

}

Limerick.java

public class Limerick extends Poem

{

private static int LINES = 5;

public Limerick(String poemName)

{

super(poemName, LINES);

}

}

Poem.java

public class Poem

{

private String poemName;

private int lines;

public Poem(String poemName, int lines)

{

this.poemName = poemName;

this.lines = lines;

}

public String getPoemName()

{

return poemName;

}

public int getLines()

{

return lines;

}

}

DemoPoem.java

import java.util.*;

public class DemoPoems

{

public static void main(String[] args)

{

Poem poem1 = new Poem("The Raven", 84);

Couplet poem2 = new Couplet("True Wit");

Limerick poem3 = new Limerick("There was an Old Man with a Beard");

Haiku poem4 = new Haiku("The Wren");

display(poem1);

display(poem2);

display(poem3);

display(poem4);

}

public static void display(Poem p)

{

System.out.println("Poem: " + p.getPoemName() +

" Lines: " + p.getLines());

}

}

Explanation:

The Couplet and Limerick classes should also be <u>extended from Poem class</u>. Also, in display method, you call getTitle(), however, it's written as getPoemName() in the <em>Poem</em> class. You need to change the name.

7 0
2 years ago
Other questions:
  • What does a sticky CTA do?
    9·2 answers
  • If you have long column labels with columns so wide that they affect the readability of a worksheet, you should first
    7·1 answer
  • What is a typical grace period for a credit card...
    15·2 answers
  • To gain experience of using and combing different sorting algorithms: election sort, insertion sort, merge sort, and quick sort.
    14·1 answer
  • When Jen is planning to upgrade to a monitor with a better resolution, what should she be looking for in the new monitor? machin
    11·1 answer
  • You'd like to change the minimum password length policy in the Default Domain Policy group policy preference (GPO). What's the b
    10·1 answer
  • Write a method that takes three numerical String values and sums their values.
    14·2 answers
  • Select the correct answer. Richard owns a chain of hardware stores. He wants to update the store website and write a numbered li
    14·1 answer
  • Television broadcasts were originally delivered by using which technology
    14·1 answer
  • Which is true regarding pseudocode
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!