SlideShare a Scribd company logo
1 of 12
Download to read offline
BasicPizza.java
public class BasicPizza {
String type;
String crust;
String ingredients;
double cost;
public BasicPizza(String type) {
super();
this.type = type;
}
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 BasicPizza() {
super();
}
public String getIngredients() {
return ingredients;
}
public void setIngredients(String ingredients) {
this.ingredients = ingredients;
}
public double getCost() {
return cost;
}
public void setCost() {
this.cost = 5;
}
@Override
public String toString() {
return "BasicPizza [type=" + type + ", crust=" + crust + ", ingredients="
+ ingredients + ", cost=" + cost + "]";
}
}
________________________________________________________________________
LiFiCheese.java
public class LiFiCheese extends BasicPizza{
private String crust;
private double cost;
private String ingredients;
public LiFiCheese() {
super("Cheese");
this.cost=5;
}
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;
}
@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 {
private String type;
private double cost;
private String crust;
private String ingredients;
public LiFiPizza()
{
super();
this.type = "Meat";
this.cost=5;
}
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;
}
@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) {
BasicPizza bp=null;
String typeOfPizza;
Scanner sc=new Scanner(System.in);
System.out.print("What type of pizza would you like :");
typeOfPizza=sc.next();
if(typeOfPizza.equalsIgnoreCase("Meat"))
{
bp=new LiFiPizza();
System.out.print("Thin or Thick Crust:");
String crust=sc.next();
bp.setCrust(crust);
System.out.print("What ingredient, sorry, only 1 :");
String ingredient=sc.next();
bp.setIngredients(ingredient);
bp.setCost();
bp.toString();
}
else if(typeOfPizza.equalsIgnoreCase("Cheese"))
{
bp=new LiFiCheese();
bp.toString();
}
}
}
_________________________________________________________________
Output:
What type of pizza would you like :Meat
Thin or Thick Crust:Thin
What ingredient, sorry, only 1 :Sausage
You Ordered :
Meat
Sausage<+$2.00>
Thin
Total Cost of :7.0
__________________________________________
Output:
What type of pizza would you like :Cheese
You Ordered :
Cheese
thin
Total Cost of :5.0
_______________________________________________________
Solution
BasicPizza.java
public class BasicPizza {
String type;
String crust;
String ingredients;
double cost;
public BasicPizza(String type) {
super();
this.type = type;
}
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 BasicPizza() {
super();
}
public String getIngredients() {
return ingredients;
}
public void setIngredients(String ingredients) {
this.ingredients = ingredients;
}
public double getCost() {
return cost;
}
public void setCost() {
this.cost = 5;
}
@Override
public String toString() {
return "BasicPizza [type=" + type + ", crust=" + crust + ", ingredients="
+ ingredients + ", cost=" + cost + "]";
}
}
________________________________________________________________________
LiFiCheese.java
public class LiFiCheese extends BasicPizza{
private String crust;
private double cost;
private String ingredients;
public LiFiCheese() {
super("Cheese");
this.cost=5;
}
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;
}
@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 {
private String type;
private double cost;
private String crust;
private String ingredients;
public LiFiPizza()
{
super();
this.type = "Meat";
this.cost=5;
}
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;
}
@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) {
BasicPizza bp=null;
String typeOfPizza;
Scanner sc=new Scanner(System.in);
System.out.print("What type of pizza would you like :");
typeOfPizza=sc.next();
if(typeOfPizza.equalsIgnoreCase("Meat"))
{
bp=new LiFiPizza();
System.out.print("Thin or Thick Crust:");
String crust=sc.next();
bp.setCrust(crust);
System.out.print("What ingredient, sorry, only 1 :");
String ingredient=sc.next();
bp.setIngredients(ingredient);
bp.setCost();
bp.toString();
}
else if(typeOfPizza.equalsIgnoreCase("Cheese"))
{
bp=new LiFiCheese();
bp.toString();
}
}
}
_________________________________________________________________
Output:
What type of pizza would you like :Meat
Thin or Thick Crust:Thin
What ingredient, sorry, only 1 :Sausage
You Ordered :
Meat
Sausage<+$2.00>
Thin
Total Cost of :7.0
__________________________________________
Output:
What type of pizza would you like :Cheese
You Ordered :
Cheese
thin
Total Cost of :5.0
_______________________________________________________

More Related Content

Similar to BasicPizza.javapublic class BasicPizza { String type; String c.pdf

Better Software: introduction to good code
Better Software: introduction to good codeBetter Software: introduction to good code
Better Software: introduction to good codeGiordano Scalzo
 
Getting the following errorsError 1 error C2436 {ctor} mem.pdf
Getting the following errorsError 1 error C2436 {ctor}  mem.pdfGetting the following errorsError 1 error C2436 {ctor}  mem.pdf
Getting the following errorsError 1 error C2436 {ctor} mem.pdfherminaherman
 
Oop php 5
Oop php 5Oop php 5
Oop php 5phpubl
 
PHPUnit でよりよくテストを書くために
PHPUnit でよりよくテストを書くためにPHPUnit でよりよくテストを書くために
PHPUnit でよりよくテストを書くためにYuya Takeyama
 
Production.javapublic class Production {    Declaring instance.pdf
Production.javapublic class Production {    Declaring instance.pdfProduction.javapublic class Production {    Declaring instance.pdf
Production.javapublic class Production {    Declaring instance.pdfsooryasalini
 
Adding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy ApplicationsAdding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy ApplicationsSam Hennessy
 
Here is the codeimport java.util.; class GroceryItem { Stri.pdf
Here is the codeimport java.util.; class GroceryItem { Stri.pdfHere is the codeimport java.util.; class GroceryItem { Stri.pdf
Here is the codeimport java.util.; class GroceryItem { Stri.pdfanand1213
 
Java: Nie popełniaj tych błędów!
Java: Nie popełniaj tych błędów!Java: Nie popełniaj tych błędów!
Java: Nie popełniaj tych błędów!Daniel Pokusa
 
MenuItemvpublic class MenuItem .pdf
MenuItemvpublic class MenuItem .pdfMenuItemvpublic class MenuItem .pdf
MenuItemvpublic class MenuItem .pdfaparnaagenciestvm
 
多治見IT勉強会 Groovy Grails
多治見IT勉強会 Groovy Grails多治見IT勉強会 Groovy Grails
多治見IT勉強会 Groovy GrailsTsuyoshi Yamamoto
 
@author public class Person{   String sname, .pdf
  @author   public class Person{   String sname, .pdf  @author   public class Person{   String sname, .pdf
@author public class Person{   String sname, .pdfaplolomedicalstoremr
 
PHP for Adults: Clean Code and Object Calisthenics
PHP for Adults: Clean Code and Object CalisthenicsPHP for Adults: Clean Code and Object Calisthenics
PHP for Adults: Clean Code and Object CalisthenicsGuilherme Blanco
 
29. Code an application program that keeps track of student informat.pdf
29. Code an application program that keeps track of student informat.pdf29. Code an application program that keeps track of student informat.pdf
29. Code an application program that keeps track of student informat.pdfarishaenterprises12
 
Modul Praktek Java OOP
Modul Praktek Java OOP Modul Praktek Java OOP
Modul Praktek Java OOP Zaenal Arifin
 
import java.util.Arrays;import java.util.List;public class Bursa.pdf
import java.util.Arrays;import java.util.List;public class Bursa.pdfimport java.util.Arrays;import java.util.List;public class Bursa.pdf
import java.util.Arrays;import java.util.List;public class Bursa.pdfarpowersarps
 
I have the following code and I need to know why I am receiving the .pdf
I have the following code and I need to know why I am receiving the .pdfI have the following code and I need to know why I am receiving the .pdf
I have the following code and I need to know why I am receiving the .pdfezzi552
 

Similar to BasicPizza.javapublic class BasicPizza { String type; String c.pdf (20)

はじめてのGroovy
はじめてのGroovyはじめてのGroovy
はじめてのGroovy
 
Solid
SolidSolid
Solid
 
Better Software: introduction to good code
Better Software: introduction to good codeBetter Software: introduction to good code
Better Software: introduction to good code
 
Getting the following errorsError 1 error C2436 {ctor} mem.pdf
Getting the following errorsError 1 error C2436 {ctor}  mem.pdfGetting the following errorsError 1 error C2436 {ctor}  mem.pdf
Getting the following errorsError 1 error C2436 {ctor} mem.pdf
 
Oop php 5
Oop php 5Oop php 5
Oop php 5
 
PHPUnit でよりよくテストを書くために
PHPUnit でよりよくテストを書くためにPHPUnit でよりよくテストを書くために
PHPUnit でよりよくテストを書くために
 
Production.javapublic class Production {    Declaring instance.pdf
Production.javapublic class Production {    Declaring instance.pdfProduction.javapublic class Production {    Declaring instance.pdf
Production.javapublic class Production {    Declaring instance.pdf
 
Adding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy ApplicationsAdding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy Applications
 
Here is the codeimport java.util.; class GroceryItem { Stri.pdf
Here is the codeimport java.util.; class GroceryItem { Stri.pdfHere is the codeimport java.util.; class GroceryItem { Stri.pdf
Here is the codeimport java.util.; class GroceryItem { Stri.pdf
 
Scala in practice
Scala in practiceScala in practice
Scala in practice
 
Java: Nie popełniaj tych błędów!
Java: Nie popełniaj tych błędów!Java: Nie popełniaj tych błędów!
Java: Nie popełniaj tych błędów!
 
MenuItemvpublic class MenuItem .pdf
MenuItemvpublic class MenuItem .pdfMenuItemvpublic class MenuItem .pdf
MenuItemvpublic class MenuItem .pdf
 
多治見IT勉強会 Groovy Grails
多治見IT勉強会 Groovy Grails多治見IT勉強会 Groovy Grails
多治見IT勉強会 Groovy Grails
 
@author public class Person{   String sname, .pdf
  @author   public class Person{   String sname, .pdf  @author   public class Person{   String sname, .pdf
@author public class Person{   String sname, .pdf
 
PHP for Adults: Clean Code and Object Calisthenics
PHP for Adults: Clean Code and Object CalisthenicsPHP for Adults: Clean Code and Object Calisthenics
PHP for Adults: Clean Code and Object Calisthenics
 
29. Code an application program that keeps track of student informat.pdf
29. Code an application program that keeps track of student informat.pdf29. Code an application program that keeps track of student informat.pdf
29. Code an application program that keeps track of student informat.pdf
 
Modul Praktek Java OOP
Modul Praktek Java OOP Modul Praktek Java OOP
Modul Praktek Java OOP
 
Oops in php
Oops in phpOops in php
Oops in php
 
import java.util.Arrays;import java.util.List;public class Bursa.pdf
import java.util.Arrays;import java.util.List;public class Bursa.pdfimport java.util.Arrays;import java.util.List;public class Bursa.pdf
import java.util.Arrays;import java.util.List;public class Bursa.pdf
 
I have the following code and I need to know why I am receiving the .pdf
I have the following code and I need to know why I am receiving the .pdfI have the following code and I need to know why I am receiving the .pdf
I have the following code and I need to know why I am receiving the .pdf
 

More from rdtraders2007

(7x14x)^12=(277x^2)^12=7x(2)^12Solution(7x14x)^12=(2.pdf
(7x14x)^12=(277x^2)^12=7x(2)^12Solution(7x14x)^12=(2.pdf(7x14x)^12=(277x^2)^12=7x(2)^12Solution(7x14x)^12=(2.pdf
(7x14x)^12=(277x^2)^12=7x(2)^12Solution(7x14x)^12=(2.pdfrdtraders2007
 
You can think of H as being heat energy added ( + ), or heat removed.pdf
You can think of H as being heat energy added ( + ), or heat removed.pdfYou can think of H as being heat energy added ( + ), or heat removed.pdf
You can think of H as being heat energy added ( + ), or heat removed.pdfrdtraders2007
 
wait, i am posting the solution.Solutionwait, i am posting the.pdf
wait, i am posting the solution.Solutionwait, i am posting the.pdfwait, i am posting the solution.Solutionwait, i am posting the.pdf
wait, i am posting the solution.Solutionwait, i am posting the.pdfrdtraders2007
 
There are many other contributing factors to the norms of culture th.pdf
There are many other contributing factors to the norms of culture th.pdfThere are many other contributing factors to the norms of culture th.pdf
There are many other contributing factors to the norms of culture th.pdfrdtraders2007
 
Thermal dimorphism is the capacity to form different structures at d.pdf
Thermal dimorphism is the capacity to form different structures at d.pdfThermal dimorphism is the capacity to form different structures at d.pdf
Thermal dimorphism is the capacity to form different structures at d.pdfrdtraders2007
 
The prime factor of 210=2357 Anyways, numbers can only be divid.pdf
The prime factor of 210=2357 Anyways, numbers can only be divid.pdfThe prime factor of 210=2357 Anyways, numbers can only be divid.pdf
The prime factor of 210=2357 Anyways, numbers can only be divid.pdfrdtraders2007
 
The OSI Reference Model layers, in order from top to bottomD. Appl.pdf
The OSI Reference Model layers, in order from top to bottomD. Appl.pdfThe OSI Reference Model layers, in order from top to bottomD. Appl.pdf
The OSI Reference Model layers, in order from top to bottomD. Appl.pdfrdtraders2007
 
Synchronous IO CPU waits till the IO proceeds.Asynchronous IO.pdf
Synchronous IO  CPU waits till the IO proceeds.Asynchronous IO.pdfSynchronous IO  CPU waits till the IO proceeds.Asynchronous IO.pdf
Synchronous IO CPU waits till the IO proceeds.Asynchronous IO.pdfrdtraders2007
 
SolutionSolutionSolution.pdf
SolutionSolutionSolution.pdfSolutionSolutionSolution.pdf
SolutionSolutionSolution.pdfrdtraders2007
 
slope = f(x) x= 12012= 10Solutionslope = f(x) x= 120.pdf
slope = f(x) x= 12012= 10Solutionslope = f(x) x= 120.pdfslope = f(x) x= 12012= 10Solutionslope = f(x) x= 120.pdf
slope = f(x) x= 12012= 10Solutionslope = f(x) x= 120.pdfrdtraders2007
 
s(s^2-b^2)Solutions(s^2-b^2).pdf
s(s^2-b^2)Solutions(s^2-b^2).pdfs(s^2-b^2)Solutions(s^2-b^2).pdf
s(s^2-b^2)Solutions(s^2-b^2).pdfrdtraders2007
 
Question not visible. Please update the question and then i can answ.pdf
Question not visible. Please update the question and then i can answ.pdfQuestion not visible. Please update the question and then i can answ.pdf
Question not visible. Please update the question and then i can answ.pdfrdtraders2007
 
Please find the required program along with the comments against eac.pdf
Please find the required program along with the comments against eac.pdfPlease find the required program along with the comments against eac.pdf
Please find the required program along with the comments against eac.pdfrdtraders2007
 
Order the steps of the viral life cycle.1. viral entry into host.pdf
Order the steps of the viral life cycle.1. viral entry into host.pdfOrder the steps of the viral life cycle.1. viral entry into host.pdf
Order the steps of the viral life cycle.1. viral entry into host.pdfrdtraders2007
 
Listing of the type of alleles present in an organisms cellGenotyp.pdf
Listing of the type of alleles present in an organisms cellGenotyp.pdfListing of the type of alleles present in an organisms cellGenotyp.pdf
Listing of the type of alleles present in an organisms cellGenotyp.pdfrdtraders2007
 
An Operating System (OS) is an interface between a computer user and.pdf
An Operating System (OS) is an interface between a computer user and.pdfAn Operating System (OS) is an interface between a computer user and.pdf
An Operating System (OS) is an interface between a computer user and.pdfrdtraders2007
 
Internal Evidence General.pdf
                    Internal Evidence                          General.pdf                    Internal Evidence                          General.pdf
Internal Evidence General.pdfrdtraders2007
 
In reaction # 3 either the cis or trans diol may .pdf
                     In reaction # 3 either the cis or trans diol may .pdf                     In reaction # 3 either the cis or trans diol may .pdf
In reaction # 3 either the cis or trans diol may .pdfrdtraders2007
 
Intermolecular forces exist between molecules and.pdf
                     Intermolecular forces exist between molecules and.pdf                     Intermolecular forces exist between molecules and.pdf
Intermolecular forces exist between molecules and.pdfrdtraders2007
 
H2 concentration will decrease and H2O concentrat.pdf
                     H2 concentration will decrease and H2O concentrat.pdf                     H2 concentration will decrease and H2O concentrat.pdf
H2 concentration will decrease and H2O concentrat.pdfrdtraders2007
 

More from rdtraders2007 (20)

(7x14x)^12=(277x^2)^12=7x(2)^12Solution(7x14x)^12=(2.pdf
(7x14x)^12=(277x^2)^12=7x(2)^12Solution(7x14x)^12=(2.pdf(7x14x)^12=(277x^2)^12=7x(2)^12Solution(7x14x)^12=(2.pdf
(7x14x)^12=(277x^2)^12=7x(2)^12Solution(7x14x)^12=(2.pdf
 
You can think of H as being heat energy added ( + ), or heat removed.pdf
You can think of H as being heat energy added ( + ), or heat removed.pdfYou can think of H as being heat energy added ( + ), or heat removed.pdf
You can think of H as being heat energy added ( + ), or heat removed.pdf
 
wait, i am posting the solution.Solutionwait, i am posting the.pdf
wait, i am posting the solution.Solutionwait, i am posting the.pdfwait, i am posting the solution.Solutionwait, i am posting the.pdf
wait, i am posting the solution.Solutionwait, i am posting the.pdf
 
There are many other contributing factors to the norms of culture th.pdf
There are many other contributing factors to the norms of culture th.pdfThere are many other contributing factors to the norms of culture th.pdf
There are many other contributing factors to the norms of culture th.pdf
 
Thermal dimorphism is the capacity to form different structures at d.pdf
Thermal dimorphism is the capacity to form different structures at d.pdfThermal dimorphism is the capacity to form different structures at d.pdf
Thermal dimorphism is the capacity to form different structures at d.pdf
 
The prime factor of 210=2357 Anyways, numbers can only be divid.pdf
The prime factor of 210=2357 Anyways, numbers can only be divid.pdfThe prime factor of 210=2357 Anyways, numbers can only be divid.pdf
The prime factor of 210=2357 Anyways, numbers can only be divid.pdf
 
The OSI Reference Model layers, in order from top to bottomD. Appl.pdf
The OSI Reference Model layers, in order from top to bottomD. Appl.pdfThe OSI Reference Model layers, in order from top to bottomD. Appl.pdf
The OSI Reference Model layers, in order from top to bottomD. Appl.pdf
 
Synchronous IO CPU waits till the IO proceeds.Asynchronous IO.pdf
Synchronous IO  CPU waits till the IO proceeds.Asynchronous IO.pdfSynchronous IO  CPU waits till the IO proceeds.Asynchronous IO.pdf
Synchronous IO CPU waits till the IO proceeds.Asynchronous IO.pdf
 
SolutionSolutionSolution.pdf
SolutionSolutionSolution.pdfSolutionSolutionSolution.pdf
SolutionSolutionSolution.pdf
 
slope = f(x) x= 12012= 10Solutionslope = f(x) x= 120.pdf
slope = f(x) x= 12012= 10Solutionslope = f(x) x= 120.pdfslope = f(x) x= 12012= 10Solutionslope = f(x) x= 120.pdf
slope = f(x) x= 12012= 10Solutionslope = f(x) x= 120.pdf
 
s(s^2-b^2)Solutions(s^2-b^2).pdf
s(s^2-b^2)Solutions(s^2-b^2).pdfs(s^2-b^2)Solutions(s^2-b^2).pdf
s(s^2-b^2)Solutions(s^2-b^2).pdf
 
Question not visible. Please update the question and then i can answ.pdf
Question not visible. Please update the question and then i can answ.pdfQuestion not visible. Please update the question and then i can answ.pdf
Question not visible. Please update the question and then i can answ.pdf
 
Please find the required program along with the comments against eac.pdf
Please find the required program along with the comments against eac.pdfPlease find the required program along with the comments against eac.pdf
Please find the required program along with the comments against eac.pdf
 
Order the steps of the viral life cycle.1. viral entry into host.pdf
Order the steps of the viral life cycle.1. viral entry into host.pdfOrder the steps of the viral life cycle.1. viral entry into host.pdf
Order the steps of the viral life cycle.1. viral entry into host.pdf
 
Listing of the type of alleles present in an organisms cellGenotyp.pdf
Listing of the type of alleles present in an organisms cellGenotyp.pdfListing of the type of alleles present in an organisms cellGenotyp.pdf
Listing of the type of alleles present in an organisms cellGenotyp.pdf
 
An Operating System (OS) is an interface between a computer user and.pdf
An Operating System (OS) is an interface between a computer user and.pdfAn Operating System (OS) is an interface between a computer user and.pdf
An Operating System (OS) is an interface between a computer user and.pdf
 
Internal Evidence General.pdf
                    Internal Evidence                          General.pdf                    Internal Evidence                          General.pdf
Internal Evidence General.pdf
 
In reaction # 3 either the cis or trans diol may .pdf
                     In reaction # 3 either the cis or trans diol may .pdf                     In reaction # 3 either the cis or trans diol may .pdf
In reaction # 3 either the cis or trans diol may .pdf
 
Intermolecular forces exist between molecules and.pdf
                     Intermolecular forces exist between molecules and.pdf                     Intermolecular forces exist between molecules and.pdf
Intermolecular forces exist between molecules and.pdf
 
H2 concentration will decrease and H2O concentrat.pdf
                     H2 concentration will decrease and H2O concentrat.pdf                     H2 concentration will decrease and H2O concentrat.pdf
H2 concentration will decrease and H2O concentrat.pdf
 

Recently uploaded

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 

Recently uploaded (20)

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 

BasicPizza.javapublic class BasicPizza { String type; String c.pdf

  • 1. BasicPizza.java public class BasicPizza { String type; String crust; String ingredients; double cost; public BasicPizza(String type) { super(); this.type = type; } 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 BasicPizza() { super(); } public String getIngredients() { return ingredients; } public void setIngredients(String ingredients) { this.ingredients = ingredients; } public double getCost() { return cost; } public void setCost() {
  • 2. this.cost = 5; } @Override public String toString() { return "BasicPizza [type=" + type + ", crust=" + crust + ", ingredients=" + ingredients + ", cost=" + cost + "]"; } } ________________________________________________________________________ LiFiCheese.java public class LiFiCheese extends BasicPizza{ private String crust; private double cost; private String ingredients; public LiFiCheese() { super("Cheese"); this.cost=5; } public void setCrust() { this.crust="thin"; } public String getCrust() { return crust; } public double getCost() { return cost; } public void setCost(double cost) { }
  • 3. public String getIngredients() { return ingredients; } public void setIngredients(String ingredients) { this.ingredients = ingredients; } @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 { private String type; private double cost; private String crust; private String ingredients; public LiFiPizza() { super(); this.type = "Meat"; this.cost=5; } public String getType() { return type;
  • 4. } 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; } @Override public String toString() { System.out.println("You Ordered :"); System.out.println(getType()); System.out.println(getIngredients()+"<+$2.00>"); System.out.println(getCrust());
  • 5. System.out.println("Total Cost of :"+getCost()); return ""; } } _____________________________________________________________________ LiFiUnit5Ch14.java import java.util.Scanner; public class LiFiUnit5Ch14 { public static void main(String[] args) { BasicPizza bp=null; String typeOfPizza; Scanner sc=new Scanner(System.in); System.out.print("What type of pizza would you like :"); typeOfPizza=sc.next(); if(typeOfPizza.equalsIgnoreCase("Meat")) { bp=new LiFiPizza(); System.out.print("Thin or Thick Crust:"); String crust=sc.next(); bp.setCrust(crust); System.out.print("What ingredient, sorry, only 1 :"); String ingredient=sc.next(); bp.setIngredients(ingredient); bp.setCost(); bp.toString(); } else if(typeOfPizza.equalsIgnoreCase("Cheese")) { bp=new LiFiCheese(); bp.toString(); } }
  • 6. } _________________________________________________________________ Output: What type of pizza would you like :Meat Thin or Thick Crust:Thin What ingredient, sorry, only 1 :Sausage You Ordered : Meat Sausage<+$2.00> Thin Total Cost of :7.0 __________________________________________ Output: What type of pizza would you like :Cheese You Ordered : Cheese thin Total Cost of :5.0 _______________________________________________________ Solution BasicPizza.java public class BasicPizza { String type; String crust; String ingredients; double cost; public BasicPizza(String type) { super(); this.type = type; } public String getType() { return type; }
  • 7. public void setType(String type) { this.type = type; } public String getCrust() { return crust; } public void setCrust(String crust) { this.crust = crust; } public BasicPizza() { super(); } public String getIngredients() { return ingredients; } public void setIngredients(String ingredients) { this.ingredients = ingredients; } public double getCost() { return cost; } public void setCost() { this.cost = 5; } @Override public String toString() { return "BasicPizza [type=" + type + ", crust=" + crust + ", ingredients=" + ingredients + ", cost=" + cost + "]"; } } ________________________________________________________________________ LiFiCheese.java public class LiFiCheese extends BasicPizza{ private String crust;
  • 8. private double cost; private String ingredients; public LiFiCheese() { super("Cheese"); this.cost=5; } 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; } @Override public String toString() { System.out.println("You Ordered :"); System.out.println(getType()); setCrust(); System.out.println(getCrust());
  • 9. System.out.println("Total Cost of :"+getCost()); return ""; } } _______________________________________________________________________ LiFiPizza.java import java.util.Scanner; public class LiFiPizza extends BasicPizza { private String type; private double cost; private String crust; private String ingredients; public LiFiPizza() { super(); this.type = "Meat"; this.cost=5; } 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) {
  • 10. 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; } @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) { BasicPizza bp=null; String typeOfPizza; Scanner sc=new Scanner(System.in); System.out.print("What type of pizza would you like :");
  • 11. typeOfPizza=sc.next(); if(typeOfPizza.equalsIgnoreCase("Meat")) { bp=new LiFiPizza(); System.out.print("Thin or Thick Crust:"); String crust=sc.next(); bp.setCrust(crust); System.out.print("What ingredient, sorry, only 1 :"); String ingredient=sc.next(); bp.setIngredients(ingredient); bp.setCost(); bp.toString(); } else if(typeOfPizza.equalsIgnoreCase("Cheese")) { bp=new LiFiCheese(); bp.toString(); } } } _________________________________________________________________ Output: What type of pizza would you like :Meat Thin or Thick Crust:Thin What ingredient, sorry, only 1 :Sausage You Ordered : Meat Sausage<+$2.00> Thin Total Cost of :7.0 __________________________________________ Output:
  • 12. What type of pizza would you like :Cheese You Ordered : Cheese thin Total Cost of :5.0 _______________________________________________________