1answer.
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
antiseptic1488 [7]
3 years ago
11

Design and implement your own simple class to represent any household item of your choice (toaster, fan, hair dryer, piano ...)

Your class should have a constructor, one additional method and at least one member variable (e.g. boolean isOn to turn the item on or off). Be sure you demonstrate your class works properly by constructing an instance of it and calling your method. Hint: check out the week 6 module readings under "additional readings". The guitar example is a good model for thisDesign and implement your own simple class to represent any household item of your choice (toaster, fan, hair dryer, piano ...) Your class should have a constructor, one additional method and at least one member variable (e.g. boolean isOn to turn the item on or off). Be sure you demonstrate your class works properly by constructing an instance of it and calling your method. Hint: check out the week 6 module readings under "additional readings". The guitar example is a good model for this..
Computers and Technology
1 answer:
emmasim [6.3K]3 years ago
8 0

Answer:

class fan{

   private String model;

   private boolean isOn;

   //Constructor goes here

   public fan(String model, boolean isOn) {

       this.model = model;

       this.isOn = isOn;

   }

   // An additional method goes here

   public boolean turnOn(boolean yes){

       if(yes) {

           this.isOn=true;

           System.out.println("Fan is blowing");

           return true;

       }

       else

           this.isOn=false;

           System.out.println("Fan is off");

           return false;

   }

}

Explanation:

Demonstrating the working of the class in a main method. Below is a complete code

public class fanTest {

   public static void main(String[] args) {

fan fan1 = new fan("Binatone", false);

       fan1.turnOn(false);

   }

}

class fan{

   private String model;

   private boolean isOn;

   //Constructor goes here

   public fan(String model, boolean isOn) {

       this.model = model;

       this.isOn = isOn;

   }

   // An additional method goes here

   public boolean turnOn(boolean yes){

       if(yes) {

           this.isOn=true;

           System.out.println("Fan is blowing");

           return true;

       }

       else

           this.isOn=false;

           System.out.println("Fan is off");

           return false;

   }

}

You might be interested in
Just-in-time management could be best defined in which of the following ways?
Tamiku [17]
The right answer for the question that is being asked and shown above is that: "c.)studying the actions and efficiency of workers." Just-in-time management could be best defined in the way of <span>c.)studying the actions and efficiency of workers</span>
4 0
3 years ago
Read 2 more answers
Prolog uses ____. Select one: a. lowercase for variable names, and uppercase for constants and functions b. uppercase for variab
Afina-wow [57]

Answer:

b) uppercase for variable names, and lowercase for constants and functions  

Explanation:

Given

Programming language: prolog

Required

The case type for variables, constants and functions

In prolog,

Variable names begin with uppercase

e.g. Name, NAME

While constants and functions begin with lowercase

e.g. name, addnumbers()

<em>Hence, (b) is correct</em>

6 0
3 years ago
The program that translate the URL into an IP address is called the _____ ?
Airida [17]

Answer:

The Correct answer is  option A: Domain Name System

Explanation:

Let look at each option;

Domain Name System:

We we type an address for example brainly website  it goes to DNS server and find the IP address of the computer where brainly website  is located. Then the request goes to the IP address. This is the mechanism of DNS.

Resource Locator:

Resource Locator is the URL For example brainly website

Web Browser:  

Web browser is a software which is used for internet browsing for example Firefox

Web Server:  

Web Server is a computer which give services to clients.

7 0
3 years ago
Read 2 more answers
Write a function named lineStats. The function lineStats takes three parameters: 1.inFile, a string that is the name of an input
luda_lava [24]

Answer:

See explaination

Explanation:

def lineStats(inFile,outFile,threshold):

# opening the input file

f=open(inFile)

# opening the file for writing output

f2=open(outFile,'w')

# reading every line in the file

for line in f:

# removing the space

line=line.strip()

# splitting the line by space

words=line.split()

# writing the number of words to the outfile file

f2.write(str(len(words))+' ')

# counter variable

count=0

# empty list

t=[]

# for every word in the words list

for word in words:

# changing the word to lower case

word=word.lower()

# checking for the length of the word greater than threshold

if len(word) > threshold:

# if the word is not in the list 't'

if word not in t:

# appending the word into the list 't'

t.append(word)

# writing the number of threshold words to the output file

f2.write(str(len(t))+'\n')

# closing the files

f.close()

f2.close()

# testing

if __name__=='__main__':

lineStats('fish.txt','fishOut.txt',3)

CONTENTS OF fish.txt:

Yes some are red and some are blue

Some are old and some are new

CONTENTS OF fishOut.txt:

8 2

7 1

CLASS CODE:

PYTHON CODE(state.py):

class State:

'''

State class is used to represent a state in a country.

'''

# constructor

def __init__(self,name):

self.name=name

self.universities=[]

# method to add university to the state

def addUniversity(self,university):

self.universities.append(university)

# method to check university is in the state or not

def is_home_of(self,university):

if university in self.universities:

return True

else:

return False

PYTHON CODE (state_test.py):

from state import State

newjersey=State('New Jersey')

newjersey.addUniversity('NJIT')

newjersey.addUniversity('Princeton')

print('New Jersey is the home of MIT :',newjersey.is_home_of('MIT'))

5 0
3 years ago
Write a for loop to print all elements in courseGrades, following each element with a space (including the last). Print forwards
ohaa [14]

Answer:

The solution code is written in C

  1. #include <stdio.h>
  2. int main()
  3. {
  4.    const int NUM_VALS = 4;
  5.    int courseGrades[NUM_VALS];
  6.    int i;
  7.    
  8.    for (i = 0; i < NUM_VALS; ++i) {
  9.        scanf("%d", &(courseGrades[i]));
  10.    }
  11.    
  12.    /* Your solution goes here */
  13.    for(i = 0; i < NUM_VALS; ++i){
  14.        printf("%d ", courseGrades[i]);
  15.    }
  16.    printf("\n");
  17.    
  18.    for(i = NUM_VALS - 1; i >=0; --i){
  19.        printf("%d ", courseGrades[i]);
  20.    }  
  21.    printf("\n");
  22.    
  23.    return 0;
  24. }

Explanation:

The solution is highlighted in the bold font.

To print the elements forward, create a for loop to start the iteration with i = 0 (Line 14). This will enable the program to get the first element and print if out followed with a space (Line 15). The program will take the second element in the next iteration.

To print the elements backward, create a for loop to start the iteration with i = NUM_VALS - 1. The NUM_VALS - 1 will give the last index of the array and therefore the loop will start printing the last element, followed the second last and so on (Line 19 - 21).

6 0
3 years ago
Other questions:
  • Easy question how the internet has impacted y’all life
    13·1 answer
  • PLEASE HELPP!! WILL MARK BRAINLIEST!!~~~~~
    11·1 answer
  • Which of the following situations best illustrates the process of authentication?a.A Web site sets users' passwords to expire ev
    7·1 answer
  • All of the following are strategies to help you prepare for standardized test except <br>​
    5·1 answer
  • When was the phone Built
    13·2 answers
  • Compared to a virtual image, a real image
    15·2 answers
  • (5 points) Create a user-defined data structure (i.e., struct) called Point that represents a two-dimensional Cartesian coordina
    5·1 answer
  • Write a program to enter RADIUS of a CIRCLE and PRINT AREA of TRIANGLE using Q Basic. (class 8)​
    9·1 answer
  • A test's directions often clarify any questions a student might have about answering a response question.
    5·2 answers
  • Which emerging technologies will have more injury on our day to day country &amp; How?​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!