Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Identify three objects that might belong to each of the following classes: a.

ID: 3855441 • Letter: 1

Question

1. Identify three objects that might belong to each of the following classes:

   a. Automobile

   b. NovelAuthor

   c. CollegeCourse

2. Identify three different classes that might contain each of these objects:

   a. Wolfgang Amadeus Mozart

   b. My pet cat named Socks

   c. Apartment 14 at 101 Main Street

3. Design a class named CustomerRecord that holds a customer number, name, and address. Include methods to set the values for each data field and output the values for each data filed.

4. a. Design a class named Book that hods a stock number, author, title, price, and number of pages for a book. Include methods to get and set the values for each data field. Write the pseudocode that defines the class.

b. Design an application program that declares two Book objects and sets and displays their values.

5. a. Design a class named Pizza. Data fields include a string field for toppings (such as pepperoni) and numeric fields for diameter in inches (such as 12) and price (such as 13.99). Include methods to get and set values for each of these fields. Write the pseudocode that defines the class.

b. Design an application program that declares two Pizza objects and sets and displays their values.

Explanation / Answer

3.

class CustomerRecord{

private int CustomerNumber;
private String name;
private String address;

public void setCustomerNuber(int no){
this.CustomerNumber = no;
}

public int getCustomerNumber(){
return this.CustomerNumber;
}

public void setAddress(String address){
this.address = address;
}

public String getAddress(){
return this.address;
}

public void setName(String name){
this.name = name;
}

public String getName(){
return this.name;
}
}

4.

public class HelloWorld{

public static void main(String []args){
Book b1 =new Book(1,"Harry potter","JK Rowling", 120,200);
Book b2 =new Book(10,"Harry potter 2","JK Rowling", 1200,2000);
System.out.println(b1.Display());
System.out.println("--------------");
System.out.println(b2.Display());
}
}


class Book {

private int stocknumber;
private String author;
private String title;
private int price;
private int pages;

Book (int stock, String name, String title, int price , int pages){
this.stocknumber= stock;
this.author = name;
this.title = title;
this.price = price;
this.pages = pages;
}

public String Display(){
return "Author name" +this.getAuthor()+" Title "+this.getTitle()
+" StockNumber "+this.getStocknumber()+" Price "+this.getPrice()+" Pages"+this.getPages();
}

public void setPages(int pages){
this.pages = pages;
}

public int getPages(){
return this.pages;
}

public void setPrice(int price){
this.price = price;
}

public int getPrice(){
return this.price;
}

public void setTitle(String title){
this.title = title;
}

public String getTitle(){
return this.title;
}
  
public void setAuthor(String author){
this.author = author;
}

public String getAuthor(){
return this.author;
}

public void setStocknumber(int no){
this.stocknumber = no;
}

public int getStocknumber(){
return this.stocknumber;
}
}

5.

public class HelloWorld{

public static void main(String []args){
Pizza b1 =new Pizza(10,"Peproni",200);
Pizza b2 =new Pizza(18,"Chicken cheese burst",2000);
System.out.println(b1.Display());
System.out.println("--------------");
System.out.println(b2.Display());
}
}


class Pizza {

private double diameter;
private String toppings;
private double price;

Pizza (double d, String topping, double price){
this.diameter= d;
this.toppings = topping;
this.price = price;
}

public String Display(){
return ("Toppings " +this.getToppings()+" Diameter "+this.getDiameter()+" Price "+this.getPrice());
}

public void setPrice(double p){
this.price = p;
}

public double getPrice(){
return this.price;
}

public void setDiameter(double d){
this.diameter = d;
}

public double getDiameter(){
return this.diameter;
}

public void setToppings(String t){
this.toppings = t;
}

public String getToppings(){
return this.toppings;
}
}