SlideShare a Scribd company logo
1 of 14
Download to read offline
BasicPizza.java
public class BasicPizza {
//Declaring instance variables
String type;
String crust;
String ingredients;
double cost;
//Default Constructor
public BasicPizza() {
super();
}
//Parameterized constructor
public BasicPizza(String type) {
super();
this.type = type;
}
//Setters and Getters
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getCrust() {
return crust;
}
public void setCrust(String crust) {
this.crust = crust;
}
public String getIngredients() {
return ingredients;
}
public void setIngredients(String ingredients) {
this.ingredients = ingredients;
}
public double getCost() {
return cost;
}
public void setCost() {
this.cost = 5;
}
//toString() method is used to display the contents of the Object.inside it.
@Override
public String toString() {
return "BasicPizza [type=" + type + ", crust=" + crust + ", ingredients="
+ ingredients + ", cost=" + cost + "]";
}
}
________________________________________________________________
LiFiCheese.java
public class LiFiCheese extends BasicPizza{
//Declaring instance variables
private String crust;
private double cost;
private String ingredients;
//Default constructor
public LiFiCheese() {
super("Cheese");
this.cost=5;
}
//Setters and getters
public void setCrust()
{
this.crust="thin";
}
public String getCrust()
{
return crust;
}
public double getCost() {
return cost;
}
public void setCost(double cost) {
}
public String getIngredients() {
return ingredients;
}
public void setIngredients(String ingredients) {
this.ingredients = ingredients;
}
//toString() method is used to display the contents of the Object.inside it.
@Override
public String toString() {
System.out.println("You Ordered :");
System.out.println(getType());
setCrust();
System.out.println(getCrust());
System.out.println("Total Cost of :"+getCost());
return "";
}
}
__________________________________________________________________________
LiFiPizza.java
import java.util.Scanner;
public class LiFiPizza extends BasicPizza {
//Declaring instance variables
private String type;
private double cost;
private String crust;
private String ingredients;
//Default constructor
public LiFiPizza()
{
super();
this.type = "Meat";
this.cost=5;
}
//Setters and getters
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public double getCost() {
return cost;
}
public void setCost() {
this.cost = this.cost+2;
}
public String getCrust() {
return crust;
}
public void setCrust(String crust) {
if(crust.equals("Thin"))
{
this.crust="Thin";
}
else if(crust.equals("Thick"))
{
this.crust="Thick";
}
}
public String getIngredients() {
return ingredients;
}
public void setIngredients(String ingredients) {
this.ingredients = ingredients;
}
//toString() method is used to display the contents of the Object.inside it.
@Override
public String toString() {
System.out.println("You Ordered :");
System.out.println(getType());
System.out.println(getIngredients()+"<+$2.00>");
System.out.println(getCrust());
System.out.println("Total Cost of :"+getCost());
return "";
}
}
________________________________________________________________________
LiFiUnit5Ch14.java
import java.util.Scanner;
public class LiFiUnit5Ch14 {
public static void main(String[] args) {
//Creating the reference of BasicPizza
BasicPizza bp=null;
//Declaring variables
String typeOfPizza;
//Scanner object is used to get the inputs entered by the user.
Scanner sc=new Scanner(System.in);
System.out.print("What type of pizza would you like :");
typeOfPizza=sc.next();
//If the user enters Meat then the if block will be executed
if(typeOfPizza.equalsIgnoreCase("Meat"))
{
//Creating the LiFiPizza Class Object
bp=new LiFiPizza();
//Getting the users choice whether it is Thin or Thick Crust
System.out.print("Thin or Thick Crust:");
String crust=sc.next();
//Calling he setter method by passing the "Thin" or "Thick" crust
bp.setCrust(crust);
//Which Extra Ingredient user wants will be read
System.out.print("What ingredient, sorry, only 1 :");
String ingredient=sc.next();
//Calling the SetIngredients method by passing the ingredient as input.
bp.setIngredients(ingredient);
bp.setCost();
bp.toString();
}
//If the user enters "cheese" then else-if block will be executed.
else if(typeOfPizza.equalsIgnoreCase("Cheese"))
{
bp=new LiFiCheese();
bp.toString();
}
}
}
____________________________________________________________________________
Output1:
What type of pizza would you like :Cheese
You Ordered :
Cheese
thin
Total Cost of :5.0
_______________________________________________________________________
Output2:
What type of pizza would you like :Meat
Thin or Thick Crust:Thin
What ingredient, sorry, only 1 :Pepperoni
You Ordered :
Meat
Pepperoni<+$2.00>
Thin
Total Cost of :7.0
____________________________________________________________________
Output3:
What type of pizza would you like :Meat
Thin or Thick Crust:Thick
What ingredient, sorry, only 1 :Sausage
You Ordered :
Meat
Sausage<+$2.00>
Thick
Total Cost of :7.0
____________________________________________________________________
Solution
BasicPizza.java
public class BasicPizza {
//Declaring instance variables
String type;
String crust;
String ingredients;
double cost;
//Default Constructor
public BasicPizza() {
super();
}
//Parameterized constructor
public BasicPizza(String type) {
super();
this.type = type;
}
//Setters and Getters
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getCrust() {
return crust;
}
public void setCrust(String crust) {
this.crust = crust;
}
public String getIngredients() {
return ingredients;
}
public void setIngredients(String ingredients) {
this.ingredients = ingredients;
}
public double getCost() {
return cost;
}
public void setCost() {
this.cost = 5;
}
//toString() method is used to display the contents of the Object.inside it.
@Override
public String toString() {
return "BasicPizza [type=" + type + ", crust=" + crust + ", ingredients="
+ ingredients + ", cost=" + cost + "]";
}
}
________________________________________________________________
LiFiCheese.java
public class LiFiCheese extends BasicPizza{
//Declaring instance variables
private String crust;
private double cost;
private String ingredients;
//Default constructor
public LiFiCheese() {
super("Cheese");
this.cost=5;
}
//Setters and getters
public void setCrust()
{
this.crust="thin";
}
public String getCrust()
{
return crust;
}
public double getCost() {
return cost;
}
public void setCost(double cost) {
}
public String getIngredients() {
return ingredients;
}
public void setIngredients(String ingredients) {
this.ingredients = ingredients;
}
//toString() method is used to display the contents of the Object.inside it.
@Override
public String toString() {
System.out.println("You Ordered :");
System.out.println(getType());
setCrust();
System.out.println(getCrust());
System.out.println("Total Cost of :"+getCost());
return "";
}
}
__________________________________________________________________________
LiFiPizza.java
import java.util.Scanner;
public class LiFiPizza extends BasicPizza {
//Declaring instance variables
private String type;
private double cost;
private String crust;
private String ingredients;
//Default constructor
public LiFiPizza()
{
super();
this.type = "Meat";
this.cost=5;
}
//Setters and getters
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public double getCost() {
return cost;
}
public void setCost() {
this.cost = this.cost+2;
}
public String getCrust() {
return crust;
}
public void setCrust(String crust) {
if(crust.equals("Thin"))
{
this.crust="Thin";
}
else if(crust.equals("Thick"))
{
this.crust="Thick";
}
}
public String getIngredients() {
return ingredients;
}
public void setIngredients(String ingredients) {
this.ingredients = ingredients;
}
//toString() method is used to display the contents of the Object.inside it.
@Override
public String toString() {
System.out.println("You Ordered :");
System.out.println(getType());
System.out.println(getIngredients()+"<+$2.00>");
System.out.println(getCrust());
System.out.println("Total Cost of :"+getCost());
return "";
}
}
________________________________________________________________________
LiFiUnit5Ch14.java
import java.util.Scanner;
public class LiFiUnit5Ch14 {
public static void main(String[] args) {
//Creating the reference of BasicPizza
BasicPizza bp=null;
//Declaring variables
String typeOfPizza;
//Scanner object is used to get the inputs entered by the user.
Scanner sc=new Scanner(System.in);
System.out.print("What type of pizza would you like :");
typeOfPizza=sc.next();
//If the user enters Meat then the if block will be executed
if(typeOfPizza.equalsIgnoreCase("Meat"))
{
//Creating the LiFiPizza Class Object
bp=new LiFiPizza();
//Getting the users choice whether it is Thin or Thick Crust
System.out.print("Thin or Thick Crust:");
String crust=sc.next();
//Calling he setter method by passing the "Thin" or "Thick" crust
bp.setCrust(crust);
//Which Extra Ingredient user wants will be read
System.out.print("What ingredient, sorry, only 1 :");
String ingredient=sc.next();
//Calling the SetIngredients method by passing the ingredient as input.
bp.setIngredients(ingredient);
bp.setCost();
bp.toString();
}
//If the user enters "cheese" then else-if block will be executed.
else if(typeOfPizza.equalsIgnoreCase("Cheese"))
{
bp=new LiFiCheese();
bp.toString();
}
}
}
____________________________________________________________________________
Output1:
What type of pizza would you like :Cheese
You Ordered :
Cheese
thin
Total Cost of :5.0
_______________________________________________________________________
Output2:
What type of pizza would you like :Meat
Thin or Thick Crust:Thin
What ingredient, sorry, only 1 :Pepperoni
You Ordered :
Meat
Pepperoni<+$2.00>
Thin
Total Cost of :7.0
____________________________________________________________________
Output3:
What type of pizza would you like :Meat
Thin or Thick Crust:Thick
What ingredient, sorry, only 1 :Sausage
You Ordered :
Meat
Sausage<+$2.00>
Thick
Total Cost of :7.0
____________________________________________________________________

More Related Content

Similar to BasicPizza.javapublic class BasicPizza { Declaring instance .pdf

can do this in java please thanks in advance The code that y.pdf
can do this in java please thanks in advance The code that y.pdfcan do this in java please thanks in advance The code that y.pdf
can do this in java please thanks in advance The code that y.pdfakshpatil4
 
Listing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdfListing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdfAnkitchhabra28
 
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdfCreat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdfaromanets
 
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdfdatabase propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdffashiionbeutycare
 
Can someone help me with this code When I run it, it stops after th.pdf
Can someone help me with this code When I run it, it stops after th.pdfCan someone help me with this code When I run it, it stops after th.pdf
Can someone help me with this code When I run it, it stops after th.pdfAmansupan
 
There is something wrong with my program-- (once I do a for view all t.pdf
There is something wrong with my program-- (once I do a for view all t.pdfThere is something wrong with my program-- (once I do a for view all t.pdf
There is something wrong with my program-- (once I do a for view all t.pdfaashienterprisesuk
 
Write a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdfWrite a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdfeyebolloptics
 
Better Software: introduction to good code
Better Software: introduction to good codeBetter Software: introduction to good code
Better Software: introduction to good codeGiordano Scalzo
 
Tested on EclipseBoth class should be in same package.pdf
Tested on EclipseBoth class should be in same package.pdfTested on EclipseBoth class should be in same package.pdf
Tested on EclipseBoth class should be in same package.pdfanupamagarud8
 
So Far I have these two classes but I need help with my persontest c.pdf
So Far I have these two classes but I need help with my persontest c.pdfSo Far I have these two classes but I need help with my persontest c.pdf
So Far I have these two classes but I need help with my persontest c.pdfarihantgiftgallery
 
assignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docx
assignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docxassignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docx
assignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docxssuser562afc1
 
Repeat Programming Project 2 in Chapter 5. This time, add the follow.pdf
Repeat Programming Project 2 in Chapter 5. This time, add the follow.pdfRepeat Programming Project 2 in Chapter 5. This time, add the follow.pdf
Repeat Programming Project 2 in Chapter 5. This time, add the follow.pdfarracollection
 
2. Create a Java class called EmployeeMain within the same project Pr.docx
 2. Create a Java class called EmployeeMain within the same project Pr.docx 2. Create a Java class called EmployeeMain within the same project Pr.docx
2. Create a Java class called EmployeeMain within the same project Pr.docxajoy21
 
How to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy CodeHow to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy CodeDaniel Wellman
 
java question Fill the add statement areaProject is to wo.pdf
java question Fill the add statement areaProject is to wo.pdfjava question Fill the add statement areaProject is to wo.pdf
java question Fill the add statement areaProject is to wo.pdfdbrienmhompsonkath75
 
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docxINTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docxnormanibarber20063
 
3. Section 3 � Complete functionality on listing screen (1.5 marks.pdf
3. Section 3 � Complete functionality on listing screen (1.5 marks.pdf3. Section 3 � Complete functionality on listing screen (1.5 marks.pdf
3. Section 3 � Complete functionality on listing screen (1.5 marks.pdfalliedscorporation
 

Similar to BasicPizza.javapublic class BasicPizza { Declaring instance .pdf (20)

can do this in java please thanks in advance The code that y.pdf
can do this in java please thanks in advance The code that y.pdfcan do this in java please thanks in advance The code that y.pdf
can do this in java please thanks in advance The code that y.pdf
 
Listing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdfListing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdf
 
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdfCreat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
 
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdfdatabase propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
 
Can someone help me with this code When I run it, it stops after th.pdf
Can someone help me with this code When I run it, it stops after th.pdfCan someone help me with this code When I run it, it stops after th.pdf
Can someone help me with this code When I run it, it stops after th.pdf
 
There is something wrong with my program-- (once I do a for view all t.pdf
There is something wrong with my program-- (once I do a for view all t.pdfThere is something wrong with my program-- (once I do a for view all t.pdf
There is something wrong with my program-- (once I do a for view all t.pdf
 
Write a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdfWrite a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdf
 
Better Software: introduction to good code
Better Software: introduction to good codeBetter Software: introduction to good code
Better Software: introduction to good code
 
Manual tecnic sergi_subirats
Manual tecnic sergi_subiratsManual tecnic sergi_subirats
Manual tecnic sergi_subirats
 
Ad java prac sol set
Ad java prac sol setAd java prac sol set
Ad java prac sol set
 
Tested on EclipseBoth class should be in same package.pdf
Tested on EclipseBoth class should be in same package.pdfTested on EclipseBoth class should be in same package.pdf
Tested on EclipseBoth class should be in same package.pdf
 
So Far I have these two classes but I need help with my persontest c.pdf
So Far I have these two classes but I need help with my persontest c.pdfSo Far I have these two classes but I need help with my persontest c.pdf
So Far I have these two classes but I need help with my persontest c.pdf
 
C# labprograms
C# labprogramsC# labprograms
C# labprograms
 
assignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docx
assignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docxassignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docx
assignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docx
 
Repeat Programming Project 2 in Chapter 5. This time, add the follow.pdf
Repeat Programming Project 2 in Chapter 5. This time, add the follow.pdfRepeat Programming Project 2 in Chapter 5. This time, add the follow.pdf
Repeat Programming Project 2 in Chapter 5. This time, add the follow.pdf
 
2. Create a Java class called EmployeeMain within the same project Pr.docx
 2. Create a Java class called EmployeeMain within the same project Pr.docx 2. Create a Java class called EmployeeMain within the same project Pr.docx
2. Create a Java class called EmployeeMain within the same project Pr.docx
 
How to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy CodeHow to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy Code
 
java question Fill the add statement areaProject is to wo.pdf
java question Fill the add statement areaProject is to wo.pdfjava question Fill the add statement areaProject is to wo.pdf
java question Fill the add statement areaProject is to wo.pdf
 
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docxINTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
 
3. Section 3 � Complete functionality on listing screen (1.5 marks.pdf
3. Section 3 � Complete functionality on listing screen (1.5 marks.pdf3. Section 3 � Complete functionality on listing screen (1.5 marks.pdf
3. Section 3 � Complete functionality on listing screen (1.5 marks.pdf
 

More from ankitmobileshop235

- You have to overcome the ionic forces of the CsI, the hydrogen bon.pdf
- You have to overcome the ionic forces of the CsI, the hydrogen bon.pdf- You have to overcome the ionic forces of the CsI, the hydrogen bon.pdf
- You have to overcome the ionic forces of the CsI, the hydrogen bon.pdfankitmobileshop235
 
#includeiostream struct node {    char value;    struct no.pdf
#includeiostream struct node {    char value;    struct no.pdf#includeiostream struct node {    char value;    struct no.pdf
#includeiostream struct node {    char value;    struct no.pdfankitmobileshop235
 
Two sp3 orbitals are filled by lone electron pair.pdf
                     Two sp3 orbitals are filled by lone electron pair.pdf                     Two sp3 orbitals are filled by lone electron pair.pdf
Two sp3 orbitals are filled by lone electron pair.pdfankitmobileshop235
 
X-Intercept is the value of x where cross x axis. Another name is .pdf
X-Intercept is the value of x where cross x axis. Another name is .pdfX-Intercept is the value of x where cross x axis. Another name is .pdf
X-Intercept is the value of x where cross x axis. Another name is .pdfankitmobileshop235
 
whether or not the viruses is not used to classify viruses.Vir.pdf
whether or not the viruses is not used to classify viruses.Vir.pdfwhether or not the viruses is not used to classify viruses.Vir.pdf
whether or not the viruses is not used to classify viruses.Vir.pdfankitmobileshop235
 
Vi may be a powerful text editor enclosed with most UNIX systems, ev.pdf
Vi may be a powerful text editor enclosed with most UNIX systems, ev.pdfVi may be a powerful text editor enclosed with most UNIX systems, ev.pdf
Vi may be a powerful text editor enclosed with most UNIX systems, ev.pdfankitmobileshop235
 
U.S management is trained to provide the executives their own career.pdf
U.S management is trained to provide the executives their own career.pdfU.S management is trained to provide the executives their own career.pdf
U.S management is trained to provide the executives their own career.pdfankitmobileshop235
 
There are many operating systemsReal-Time Operating SystemReal-t.pdf
There are many operating systemsReal-Time Operating SystemReal-t.pdfThere are many operating systemsReal-Time Operating SystemReal-t.pdf
There are many operating systemsReal-Time Operating SystemReal-t.pdfankitmobileshop235
 
The three major forms of business organizations are1. Sole Propri.pdf
The three major forms of business organizations are1. Sole Propri.pdfThe three major forms of business organizations are1. Sole Propri.pdf
The three major forms of business organizations are1. Sole Propri.pdfankitmobileshop235
 
the OSI model is an idea. it is abstract it has no value without imp.pdf
the OSI model is an idea. it is abstract it has no value without imp.pdfthe OSI model is an idea. it is abstract it has no value without imp.pdf
the OSI model is an idea. it is abstract it has no value without imp.pdfankitmobileshop235
 
The EVA metric effectively measures the amount of shareholder wealth.pdf
The EVA metric effectively measures the amount of shareholder wealth.pdfThe EVA metric effectively measures the amount of shareholder wealth.pdf
The EVA metric effectively measures the amount of shareholder wealth.pdfankitmobileshop235
 
Reflection about the centre of the pentagon is not its symmetric and.pdf
Reflection about the centre of the pentagon is not its symmetric and.pdfReflection about the centre of the pentagon is not its symmetric and.pdf
Reflection about the centre of the pentagon is not its symmetric and.pdfankitmobileshop235
 
Question not visible. Please state again.SolutionQuestion not .pdf
Question not visible. Please state again.SolutionQuestion not .pdfQuestion not visible. Please state again.SolutionQuestion not .pdf
Question not visible. Please state again.SolutionQuestion not .pdfankitmobileshop235
 
Per my quiz, it was also D) formation of the carbocatio or bromonium.pdf
Per my quiz, it was also D) formation of the carbocatio or bromonium.pdfPer my quiz, it was also D) formation of the carbocatio or bromonium.pdf
Per my quiz, it was also D) formation of the carbocatio or bromonium.pdfankitmobileshop235
 
Part ATay-Sachs disease is an autosomal recessive disorder, so, o.pdf
Part ATay-Sachs disease is an autosomal recessive disorder, so, o.pdfPart ATay-Sachs disease is an autosomal recessive disorder, so, o.pdf
Part ATay-Sachs disease is an autosomal recessive disorder, so, o.pdfankitmobileshop235
 
null is a subset of every setTrueSolutionnull is a sub.pdf
null is a subset of every setTrueSolutionnull is a sub.pdfnull is a subset of every setTrueSolutionnull is a sub.pdf
null is a subset of every setTrueSolutionnull is a sub.pdfankitmobileshop235
 
Information is a valuable asset that can make or break your business.pdf
Information is a valuable asset that can make or break your business.pdfInformation is a valuable asset that can make or break your business.pdf
Information is a valuable asset that can make or break your business.pdfankitmobileshop235
 
Ho there is no relationship between the age of the individual and t.pdf
Ho there is no relationship between the age of the individual and t.pdfHo there is no relationship between the age of the individual and t.pdf
Ho there is no relationship between the age of the individual and t.pdfankitmobileshop235
 
H2SO3 - H2O = SO2The oxide is sulfur dioxide SO2SolutionH2.pdf
H2SO3 - H2O = SO2The oxide is sulfur dioxide SO2SolutionH2.pdfH2SO3 - H2O = SO2The oxide is sulfur dioxide SO2SolutionH2.pdf
H2SO3 - H2O = SO2The oxide is sulfur dioxide SO2SolutionH2.pdfankitmobileshop235
 

More from ankitmobileshop235 (20)

- You have to overcome the ionic forces of the CsI, the hydrogen bon.pdf
- You have to overcome the ionic forces of the CsI, the hydrogen bon.pdf- You have to overcome the ionic forces of the CsI, the hydrogen bon.pdf
- You have to overcome the ionic forces of the CsI, the hydrogen bon.pdf
 
#includeiostream struct node {    char value;    struct no.pdf
#includeiostream struct node {    char value;    struct no.pdf#includeiostream struct node {    char value;    struct no.pdf
#includeiostream struct node {    char value;    struct no.pdf
 
Two sp3 orbitals are filled by lone electron pair.pdf
                     Two sp3 orbitals are filled by lone electron pair.pdf                     Two sp3 orbitals are filled by lone electron pair.pdf
Two sp3 orbitals are filled by lone electron pair.pdf
 
X-Intercept is the value of x where cross x axis. Another name is .pdf
X-Intercept is the value of x where cross x axis. Another name is .pdfX-Intercept is the value of x where cross x axis. Another name is .pdf
X-Intercept is the value of x where cross x axis. Another name is .pdf
 
whether or not the viruses is not used to classify viruses.Vir.pdf
whether or not the viruses is not used to classify viruses.Vir.pdfwhether or not the viruses is not used to classify viruses.Vir.pdf
whether or not the viruses is not used to classify viruses.Vir.pdf
 
Vi may be a powerful text editor enclosed with most UNIX systems, ev.pdf
Vi may be a powerful text editor enclosed with most UNIX systems, ev.pdfVi may be a powerful text editor enclosed with most UNIX systems, ev.pdf
Vi may be a powerful text editor enclosed with most UNIX systems, ev.pdf
 
U.S management is trained to provide the executives their own career.pdf
U.S management is trained to provide the executives their own career.pdfU.S management is trained to provide the executives their own career.pdf
U.S management is trained to provide the executives their own career.pdf
 
There are many operating systemsReal-Time Operating SystemReal-t.pdf
There are many operating systemsReal-Time Operating SystemReal-t.pdfThere are many operating systemsReal-Time Operating SystemReal-t.pdf
There are many operating systemsReal-Time Operating SystemReal-t.pdf
 
The three major forms of business organizations are1. Sole Propri.pdf
The three major forms of business organizations are1. Sole Propri.pdfThe three major forms of business organizations are1. Sole Propri.pdf
The three major forms of business organizations are1. Sole Propri.pdf
 
the OSI model is an idea. it is abstract it has no value without imp.pdf
the OSI model is an idea. it is abstract it has no value without imp.pdfthe OSI model is an idea. it is abstract it has no value without imp.pdf
the OSI model is an idea. it is abstract it has no value without imp.pdf
 
The EVA metric effectively measures the amount of shareholder wealth.pdf
The EVA metric effectively measures the amount of shareholder wealth.pdfThe EVA metric effectively measures the amount of shareholder wealth.pdf
The EVA metric effectively measures the amount of shareholder wealth.pdf
 
Reflection about the centre of the pentagon is not its symmetric and.pdf
Reflection about the centre of the pentagon is not its symmetric and.pdfReflection about the centre of the pentagon is not its symmetric and.pdf
Reflection about the centre of the pentagon is not its symmetric and.pdf
 
Question not visible. Please state again.SolutionQuestion not .pdf
Question not visible. Please state again.SolutionQuestion not .pdfQuestion not visible. Please state again.SolutionQuestion not .pdf
Question not visible. Please state again.SolutionQuestion not .pdf
 
Per my quiz, it was also D) formation of the carbocatio or bromonium.pdf
Per my quiz, it was also D) formation of the carbocatio or bromonium.pdfPer my quiz, it was also D) formation of the carbocatio or bromonium.pdf
Per my quiz, it was also D) formation of the carbocatio or bromonium.pdf
 
Part ATay-Sachs disease is an autosomal recessive disorder, so, o.pdf
Part ATay-Sachs disease is an autosomal recessive disorder, so, o.pdfPart ATay-Sachs disease is an autosomal recessive disorder, so, o.pdf
Part ATay-Sachs disease is an autosomal recessive disorder, so, o.pdf
 
null is a subset of every setTrueSolutionnull is a sub.pdf
null is a subset of every setTrueSolutionnull is a sub.pdfnull is a subset of every setTrueSolutionnull is a sub.pdf
null is a subset of every setTrueSolutionnull is a sub.pdf
 
LiOH Sol.pdf
                     LiOH                                      Sol.pdf                     LiOH                                      Sol.pdf
LiOH Sol.pdf
 
Information is a valuable asset that can make or break your business.pdf
Information is a valuable asset that can make or break your business.pdfInformation is a valuable asset that can make or break your business.pdf
Information is a valuable asset that can make or break your business.pdf
 
Ho there is no relationship between the age of the individual and t.pdf
Ho there is no relationship between the age of the individual and t.pdfHo there is no relationship between the age of the individual and t.pdf
Ho there is no relationship between the age of the individual and t.pdf
 
H2SO3 - H2O = SO2The oxide is sulfur dioxide SO2SolutionH2.pdf
H2SO3 - H2O = SO2The oxide is sulfur dioxide SO2SolutionH2.pdfH2SO3 - H2O = SO2The oxide is sulfur dioxide SO2SolutionH2.pdf
H2SO3 - H2O = SO2The oxide is sulfur dioxide SO2SolutionH2.pdf
 

Recently uploaded

Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnershipsexpandedwebsite
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSean M. Fox
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsSandeep D Chaudhary
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文中 央社
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppCeline George
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital ManagementMBA Assignment Experts
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjMohammed Sikander
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint23600690
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17Celine George
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...Nguyen Thanh Tu Collection
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppCeline George
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhleson0603
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxLimon Prince
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...EduSkills OECD
 

Recently uploaded (20)

Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 

BasicPizza.javapublic class BasicPizza { Declaring instance .pdf

  • 1. BasicPizza.java public class BasicPizza { //Declaring instance variables String type; String crust; String ingredients; double cost; //Default Constructor public BasicPizza() { super(); } //Parameterized constructor public BasicPizza(String type) { super(); this.type = type; } //Setters and Getters public String getType() { return type; } public void setType(String type) { this.type = type; } public String getCrust() { return crust; } public void setCrust(String crust) { this.crust = crust; } public String getIngredients() { return ingredients; }
  • 2. public void setIngredients(String ingredients) { this.ingredients = ingredients; } public double getCost() { return cost; } public void setCost() { this.cost = 5; } //toString() method is used to display the contents of the Object.inside it. @Override public String toString() { return "BasicPizza [type=" + type + ", crust=" + crust + ", ingredients=" + ingredients + ", cost=" + cost + "]"; } } ________________________________________________________________ LiFiCheese.java public class LiFiCheese extends BasicPizza{ //Declaring instance variables private String crust; private double cost; private String ingredients; //Default constructor public LiFiCheese() { super("Cheese"); this.cost=5; } //Setters and getters public void setCrust() { this.crust="thin";
  • 3. } public String getCrust() { return crust; } public double getCost() { return cost; } public void setCost(double cost) { } public String getIngredients() { return ingredients; } public void setIngredients(String ingredients) { this.ingredients = ingredients; } //toString() method is used to display the contents of the Object.inside it. @Override public String toString() { System.out.println("You Ordered :"); System.out.println(getType()); setCrust(); System.out.println(getCrust()); System.out.println("Total Cost of :"+getCost()); return ""; } } __________________________________________________________________________ LiFiPizza.java
  • 4. import java.util.Scanner; public class LiFiPizza extends BasicPizza { //Declaring instance variables private String type; private double cost; private String crust; private String ingredients; //Default constructor public LiFiPizza() { super(); this.type = "Meat"; this.cost=5; } //Setters and getters public String getType() { return type; } public void setType(String type) { this.type = type; } public double getCost() { return cost; } public void setCost() { this.cost = this.cost+2; } public String getCrust() { return crust; } public void setCrust(String crust) { if(crust.equals("Thin")) { this.crust="Thin";
  • 5. } else if(crust.equals("Thick")) { this.crust="Thick"; } } public String getIngredients() { return ingredients; } public void setIngredients(String ingredients) { this.ingredients = ingredients; } //toString() method is used to display the contents of the Object.inside it. @Override public String toString() { System.out.println("You Ordered :"); System.out.println(getType()); System.out.println(getIngredients()+"<+$2.00>"); System.out.println(getCrust()); System.out.println("Total Cost of :"+getCost()); return ""; } } ________________________________________________________________________ LiFiUnit5Ch14.java import java.util.Scanner; public class LiFiUnit5Ch14 { public static void main(String[] args) { //Creating the reference of BasicPizza BasicPizza bp=null; //Declaring variables String typeOfPizza;
  • 6. //Scanner object is used to get the inputs entered by the user. Scanner sc=new Scanner(System.in); System.out.print("What type of pizza would you like :"); typeOfPizza=sc.next(); //If the user enters Meat then the if block will be executed if(typeOfPizza.equalsIgnoreCase("Meat")) { //Creating the LiFiPizza Class Object bp=new LiFiPizza(); //Getting the users choice whether it is Thin or Thick Crust System.out.print("Thin or Thick Crust:"); String crust=sc.next(); //Calling he setter method by passing the "Thin" or "Thick" crust bp.setCrust(crust); //Which Extra Ingredient user wants will be read System.out.print("What ingredient, sorry, only 1 :"); String ingredient=sc.next(); //Calling the SetIngredients method by passing the ingredient as input. bp.setIngredients(ingredient); bp.setCost(); bp.toString(); } //If the user enters "cheese" then else-if block will be executed. else if(typeOfPizza.equalsIgnoreCase("Cheese")) { bp=new LiFiCheese(); bp.toString(); }
  • 7. } } ____________________________________________________________________________ Output1: What type of pizza would you like :Cheese You Ordered : Cheese thin Total Cost of :5.0 _______________________________________________________________________ Output2: What type of pizza would you like :Meat Thin or Thick Crust:Thin What ingredient, sorry, only 1 :Pepperoni You Ordered : Meat Pepperoni<+$2.00> Thin Total Cost of :7.0 ____________________________________________________________________ Output3: What type of pizza would you like :Meat Thin or Thick Crust:Thick What ingredient, sorry, only 1 :Sausage You Ordered : Meat Sausage<+$2.00> Thick Total Cost of :7.0 ____________________________________________________________________ Solution BasicPizza.java
  • 8. public class BasicPizza { //Declaring instance variables String type; String crust; String ingredients; double cost; //Default Constructor public BasicPizza() { super(); } //Parameterized constructor public BasicPizza(String type) { super(); this.type = type; } //Setters and Getters public String getType() { return type; } public void setType(String type) { this.type = type; } public String getCrust() { return crust; } public void setCrust(String crust) { this.crust = crust; } public String getIngredients() { return ingredients; } public void setIngredients(String ingredients) { this.ingredients = ingredients;
  • 9. } public double getCost() { return cost; } public void setCost() { this.cost = 5; } //toString() method is used to display the contents of the Object.inside it. @Override public String toString() { return "BasicPizza [type=" + type + ", crust=" + crust + ", ingredients=" + ingredients + ", cost=" + cost + "]"; } } ________________________________________________________________ LiFiCheese.java public class LiFiCheese extends BasicPizza{ //Declaring instance variables private String crust; private double cost; private String ingredients; //Default constructor public LiFiCheese() { super("Cheese"); this.cost=5; } //Setters and getters public void setCrust() { this.crust="thin"; } public String getCrust()
  • 10. { return crust; } public double getCost() { return cost; } public void setCost(double cost) { } public String getIngredients() { return ingredients; } public void setIngredients(String ingredients) { this.ingredients = ingredients; } //toString() method is used to display the contents of the Object.inside it. @Override public String toString() { System.out.println("You Ordered :"); System.out.println(getType()); setCrust(); System.out.println(getCrust()); System.out.println("Total Cost of :"+getCost()); return ""; } } __________________________________________________________________________ LiFiPizza.java import java.util.Scanner; public class LiFiPizza extends BasicPizza {
  • 11. //Declaring instance variables private String type; private double cost; private String crust; private String ingredients; //Default constructor public LiFiPizza() { super(); this.type = "Meat"; this.cost=5; } //Setters and getters public String getType() { return type; } public void setType(String type) { this.type = type; } public double getCost() { return cost; } public void setCost() { this.cost = this.cost+2; } public String getCrust() { return crust; } public void setCrust(String crust) { if(crust.equals("Thin")) { this.crust="Thin"; } else if(crust.equals("Thick"))
  • 12. { this.crust="Thick"; } } public String getIngredients() { return ingredients; } public void setIngredients(String ingredients) { this.ingredients = ingredients; } //toString() method is used to display the contents of the Object.inside it. @Override public String toString() { System.out.println("You Ordered :"); System.out.println(getType()); System.out.println(getIngredients()+"<+$2.00>"); System.out.println(getCrust()); System.out.println("Total Cost of :"+getCost()); return ""; } } ________________________________________________________________________ LiFiUnit5Ch14.java import java.util.Scanner; public class LiFiUnit5Ch14 { public static void main(String[] args) { //Creating the reference of BasicPizza BasicPizza bp=null; //Declaring variables String typeOfPizza; //Scanner object is used to get the inputs entered by the user. Scanner sc=new Scanner(System.in);
  • 13. System.out.print("What type of pizza would you like :"); typeOfPizza=sc.next(); //If the user enters Meat then the if block will be executed if(typeOfPizza.equalsIgnoreCase("Meat")) { //Creating the LiFiPizza Class Object bp=new LiFiPizza(); //Getting the users choice whether it is Thin or Thick Crust System.out.print("Thin or Thick Crust:"); String crust=sc.next(); //Calling he setter method by passing the "Thin" or "Thick" crust bp.setCrust(crust); //Which Extra Ingredient user wants will be read System.out.print("What ingredient, sorry, only 1 :"); String ingredient=sc.next(); //Calling the SetIngredients method by passing the ingredient as input. bp.setIngredients(ingredient); bp.setCost(); bp.toString(); } //If the user enters "cheese" then else-if block will be executed. else if(typeOfPizza.equalsIgnoreCase("Cheese")) { bp=new LiFiCheese(); bp.toString(); } }
  • 14. } ____________________________________________________________________________ Output1: What type of pizza would you like :Cheese You Ordered : Cheese thin Total Cost of :5.0 _______________________________________________________________________ Output2: What type of pizza would you like :Meat Thin or Thick Crust:Thin What ingredient, sorry, only 1 :Pepperoni You Ordered : Meat Pepperoni<+$2.00> Thin Total Cost of :7.0 ____________________________________________________________________ Output3: What type of pizza would you like :Meat Thin or Thick Crust:Thick What ingredient, sorry, only 1 :Sausage You Ordered : Meat Sausage<+$2.00> Thick Total Cost of :7.0 ____________________________________________________________________