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
Aleks [24]
3 years ago
4

Create an ItemSold class for Francis Pet Supply. Fields include an invoice number, description, and price. Create get and set me

thods for each field. Create a subclass named PetSold that descends from ItemSold and includes three Boolean fields that indicate whether the pet has been vaccinated, neutered, and housebroken, and include get and set methods for these fields. Write an application that creates two objects of each class, and demonstrate that all the methods work correctly. Save the files as ItemSold.java, PetSold.java, and DemoItemsAndPets.java.
Engineering
1 answer:
finlep [7]3 years ago
4 0

Answer:

The program to this question can be given as:

Program:

class ItemSold //define class.  

{  

private int invoiceNumber; //define variable  

private String description;  

private float price;  

/define parameterized constructor.  

ItemSold(int invoiceNumber, String description, float price)  

{  

this. invoiceNumber = invoiceNumber;  

this. description = description;  

this. price = price;  

}  

public int getInvoiceNum() //define function.  

{  

return invoiceNumber; //return value.  

}  

public void setInvoiceNum(int invoiceNumber) //define function

{  

this. invoiceNumber = invoiceNumber; //hold value.  

}

public String getDescription() //define function.  

{  

return description; //return value  

}  

public void setDescription(String description) //define function.

{  

this. description = description; //hold value.  

}  

public float getPrice() //define function

{  

return price; //return value  

}  

public void setPrice(float price)  

{  

this. price = price; //hold value.  

}  

}  

class PetSold extends ItemSold //define class.

{  

private Boolean vaccinated; //define variable  

private Boolean neutered;  

private Boolean housebroken;

//parameterized constructor  

PetSold(int invoiceNumber, String description, float price, Boolean vaccinated, Boolean neutered, Boolean housebroken)  

{  

super(invoiceNumber, description, price); //use super function.  

this.vaccinated = vaccinated; //holding value.  

this.neutered = neutered;  

this.housebroken = housebroken;  

}  

public Boolean isVaccinated() //define function .  

{  

return vaccinated; //return value.  

}  

public void setVaccinated(Boolean vaccinated) //define function  

{  

this. vaccinated = vaccinated; //holding value  

}  

public Boolean isNeutered() //define function  

{  

return neutered; //return value  

}  

public void setNeutered(Boolean neutered) //define function  

{

this. neutered = neutered; //holding value  

}

public Boolean isHousebroken() //define function.  

{  

return housebroken; //return value  

}  

public void setHousebroken(Boolean housebroken) //define function  

{  

this. housebroken = housebroken; //holding value  

}  

}  

public class DemoItemsAndPets //define class.

{  

public static void main(String[] args) //define Main function  

{  

ItemSold ob1 = new ItemSold(101,"mug",6.95f); //creating Object of ItemSold class & call constructor.  

//creating Object of PetSold class & call constructor.  

PetSold ob2 = new PetSold(102,"The book of love",234.97f,true,true,false);  

System.out.print(ob1.getDescription() + " was sold for " + ob1.getPrice());  

System.out.print(ob2.getDescription() + " was sold in " + ob2.getPrice());  

System.out.print(ob2.getDescription() + " Neutered status is: " + ob2.isNeutered() +  

"\nAnd it is " + ob2.isHousebroken() + " that " + ob2.getDescription() +" is housebroken");  

}  

}  

Output:

mug was sold in 6.95

The book of love was sold in 234.97.

The book of love Neutered status is: true.

And it is false that The book of love is housebroken.

Explanation:

In this program firstly we declare the class that's name is already given in the question. The class name is ItemSold.java, PetSold.java, and DemoItemsAndPets.java. In the ItemSold and PetSold class, we use the variable as a private, parameterized constructor and function. The variable is used for initializing the value in the constructor and the function is used for return and sets the value. In this class, there are two functions for each variable i.e get and set. The get function is used to return the value and set function is used to set the value. At the lass we define the main class that is DemoItemsAndPets in this class we create above class objects and pass the value in the constructor and print its value.

You might be interested in
What is the capacity of the machine in batches?
Valentin [98]
28 batches per day and the setup time is five minutes
3 0
4 years ago
In the action adventure film Indiana Jones and the Raiders of the Lost Ark, Indiana Jones searches for the Ark of the Covenant.
zhuklara [117]

Answer:

hshhshuwuuwhhwbbdhuuduuwhbshbd ushwhhhsbdb hsuhsheuudhhe sujehhe

7 0
3 years ago
A particular motor rotates at 3000 revolutions per minute. What is its speed in rad/sec, and how many seconds does it takes to m
Leno4ka [110]

Answer:

ω=314.15 rad/s.

0.02 s.

Explanation:

Given that

Motor speed ,N= 3000 revolutions per minute

N= 3000 RPM

The speed of the motor in rad/s given as

\omega=\dfrac{2\pi N}{60}\ rad/s

Now by putting the values in the above equation

\omega=\dfrac{2\pi \times 3000}{60}\ rad/s

ω=314.15 rad/s

Therefore the speed in rad/s will be 314.15 rad/s.

The speed in rev/sec given as

\omega=\dfrac{ 3000}{60}\ rad/s

ω= 50 rev/s

It take 1 sec to cover 50 revolutions

That is why to cover 1 revolution it take

\dfrac{1}{50}=0.02\ s

4 0
3 years ago
19/32 reduced to its lowest form
d1i1m1o1n [39]

Answer:

19/32

Explanation:

19/32 is already in its lowest form

8 0
3 years ago
Read 2 more answers
Which option demonstrates what will happen once a prototype is developed
Xelga [282]

Answer:

just free your mind drink water and go outside take fresh air you will get answers.

Explanation:

This a best method to solve the answer.I hope it is helpful

8 0
4 years ago
Other questions:
  • A railcar with an overall mass of 78,000 kg traveling with a speed vi is approaching a barrier equipped with a bumper consisting
    15·1 answer
  • An inductor (L = 400 mH), a capacitor (C = 4.43 µF), and a resistor (R = 500 Ω) are connected in series. A 44.0-Hz AC generator
    11·1 answer
  • A hydraulic jump is induced in an 80 ft wide channel.The water depths on either side of the jump are 1 ft and 10 ft.Please calcu
    5·2 answers
  • A hair dryer is basically a duct of constant diameter in which a few layers of electric resistors are placed. A small fan pulls
    7·1 answer
  • Choose the best compression ratio for an Otto cycle reciprocating engine: a. 5 b. 10 c. 15 d. 20
    14·1 answer
  •  Question 1. CVP exercises. The Doral Company manufactures and sells pens. Currently, 5,000,000 units are sold per year at $0.5
    8·1 answer
  • Assume that a chocolate bar consists of n squares ar- ranged in a rectangular pattern. The entire bar, or any smaller rectangula
    8·1 answer
  • Which one is an example of a digital input?
    5·1 answer
  • Explain when single-stranded or multistranded wire should be used.
    13·1 answer
  • When converting liquid level units to sensor output signal units, you should first convert the liquid level units to _____ units
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!