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
Julli [10]
3 years ago
9

In Java: Write a class called Shelf that contains instance data that repre-sents the length, breadth, and capacity of the shelf.

Also include a boolean variable called occupied as instance data that repre-sents whether the shelf is occupied or not. Define the Shelf con-structor to accept and initialize the height, width, and capacity of the shelf. Each newly created Shelf is vacant (the constructor should initialize occupied to false). Include getter and setter methods for all instance data. Include a toString method that returns a one-line description of the shelf. Create a driver class called ShelfCheck, whose main method instantiates and updates several Shelf objects.
Computers and Technology
1 answer:
disa [49]3 years ago
5 0

Answer:see explanation

Explanation:

Hello, the solution is the following:

in a file named Shelf.java :

public class Shelf{

   int length;

   int breadth;

   int capacity;

   boolean occupied;

   Shelf(int length,int breadth, int capacity){

       this.length = length;

       this.breadth = breadth;

       this.capacity = capacity;

       this.occupied = false;

   }

   

   //set methods

   public void setLength(int length){

       this.length = length;

   }

   public void setBreadth(int breadth){

       this.breadth = breadth;

   }

   public void setCapacity(int capacity){

       this.capacity = capacity;

   }

   public void setOccupied(boolean occupied){

       this.occupied = occupied;

   }

   

   //get methods

   public int getLength(){

       return this.length;

   }

   public int getBreadth(){

       return this.breadth;

   }

   public int getCapacity(){

       return this.capacity;

   }

   public boolean getOccupied(){

       return this.occupied;

   }

   

   //tostring method

   

   public String toString(){//overriding the toString() method  

 return "Shelf: \n"+" length: "+Integer.toString(this.length)+" breadth: "+Integer.toString(this.breadth)+" capacity: "+Integer.toString(this.capacity)+" occupied: "+Boolean.toString(this.occupied);

}  

}

in another file named ShelfCheck.java

public class ShelfCheck {

 public static void main(String[] args) {

   Shelf s1=new Shelf(100,150,300);

   Shelf s2=new Shelf(200,200,234);  

   Shelf s3=new Shelf(300,222,543);  

   Shelf s4=new Shelf(400,434,654);

   System.out.println(s1);

   System.out.println(s2);

   System.out.println(s3);

   System.out.println(s4);

   s4.setLength(5);

   System.out.println(s4);

   s2.setBreadth(2);

   System.out.println(s2);

   s3.setCapacity(1);

   System.out.println(s3);

   s1.setOccupied(true);

   System.out.println(s1);

 }

}

OUTPUT:

Shelf:

length: 100 breadth: 150 capacity: 300 occupied: false

Shelf:

length: 200 breadth: 200 capacity: 234 occupied: false

Shelf:

length: 300 breadth: 222 capacity: 543 occupied: false

Shelf:

length: 400 breadth: 434 capacity: 654 occupied: false

Shelf:

length: 5 breadth: 434 capacity: 654 occupied: false

Shelf:

length: 200 breadth: 2 capacity: 234 occupied: false

Shelf:

length: 300 breadth: 222 capacity: 1 occupied: false

Shelf:

length: 100 breadth: 150 capacity: 300 occupied: true

You might be interested in
How do you think advances in processors affect corporations that discover the computers they purchased just a couple of years ag
lozanna [386]

Answer:

Increased processor speed and multi core technologies.

Explanation:

The development of processors over the years is overwhelmingly fast. The CPU use to be cumbersome, expensive and computational speed was moderate.

As it evolves, the CPU was minimized to give rise to microprocessors.

Microprocessors are very fast, running millions of processes on its core. The multiple core processors helped to increase the speed of these processors.

When there are more than one core in a processor (dual, quad or octal core), it processes data in parallel reducing the time of execution compared to a one core processor.

A company having computers with single core would need to upgrade to a new computer with multi core processor to promote speed in data processing.

3 0
3 years ago
When you’re in the Normal view, what are the visible panes?
zheka24 [161]

a

pleas give branlest

6 0
3 years ago
Read 2 more answers
Lucinda is a network manager. She wants to set up a small office computer network so that it will not be affected at all by elec
Katena32 [7]

Answer:

The network media she should use is;

E. Shielded twisted-pair

Explanation:

A network connection that will not be affected by electrical or electromagnetic interference is a shielded twisted pair cable

Electromagnetic interference, EMI, is an externally originating disturbance that has an impact on electrical circuits through electromagnetic induction, direct conduction, or electrostatic coupling, with the possible effect of circuit degradation or disruption

EMI can be prevented by the use of shielded twisted pair (STP) cabling that provides a barrier that reduces the effect of external electromagnetic fields and transports the current induced to the ground through a grounding wire

4 0
3 years ago
If you paste a word document text into an excel spreadsheet, the paste optio allow you to keep source formatting or
castortr0y [4]
I think the answer is c
6 0
3 years ago
Sally needs to teach her class how to convert a decimal number to a binary number. What is the first step she should take to sta
Alborosie

<u>Answer:</u>

  • <em>A. divide the decimal number by the base value 2</em>
  • <em>C. note the remainder separately</em>
  • <em>D. divide by 2 until she gets 0 as the remainder</em>
  • <em>B. collect the digits in the reverse order</em>

<u>Explanation:</u>

When we want to convert decimal number to a binary number first we have divide the given number by 2. The next step is to note the reminder of the number in the side every division so that the reminder value is the binary value. Repeat this until an zero is encountered.

We have to collate all the remainders from last of first and then the collated number is the answer for the given problem.

<em>So the given option can be ordered as, </em>

  • <em>A</em>
  • <em>C</em>
  • <em>D</em>
  • <em>B</em>
6 0
4 years ago
Other questions:
  • Jimmy is running out of desk space. He keeps three computers on his desk. The three computers can’t be moved, and they need to b
    5·2 answers
  • In which of the following situations will a macro make your work more efficient?
    7·1 answer
  • E-mail is an temporary message medium.<br> a. True<br> b. False
    5·2 answers
  • Rob Janoff believes that technology should not be used too
    11·1 answer
  • Write a program segment that simulates flipping a coin 25 times by generating and displaying 25 random integers, each of which i
    5·1 answer
  • Apollo Couriers, a company providing international express mail services, has a proactive customer communications team. The prim
    8·1 answer
  • Which of the following is considered technology?
    12·1 answer
  • When you see this traffic signal is turned on, you may _____________________.
    5·2 answers
  • You are installing a single 802.11g wireless network. The office space is large enough that you need three WAPs. What channels s
    10·1 answer
  • What are the OSHA construction standards also called ?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!