Question: Why do I not need to create a Carly object for the Carly class in the CarlyEventDemo class when I need to make an object
Why do I not need to create a Carly object for the Carly class in the CarlyEventDemo class when I need to make an object for the CarlyEvent class? Code below and any explanation would be greatly appreciated.
import java.util.Scanner;
public class Carly
public static void mainString args
variable
int guests;
CarlyEvent event new CarlyEvent;
motto;
guests numGuests;
priceguests;
public static int numGuests
variable
int numOfGuests;
Scanner
Scanner input new ScannerSystemin;
System.out.printlnHow many people will be attending the event? ;
numOfGuests input.nextInt;
return numOfGuests;
public static void motto
motto
System.out.println;
System.out.println;
System.out.println Carly's makes the food that makes it a party. ;
System.out.println;
System.out.println;
public static void priceint guests
int ticketCost ;
int total;
total guests ticketCost;
System.out.printlnYou have guests guests attending the event, thus the total price is $ total;
boolean largeEvent guests ;
System.out.printlnLarge event: largeEvent;
public static String getEventNum
variable
String eventNumber;
Scanner input new ScannerSystemin;
System.out.printlnWhat is the event number? ;
eventNumber input.next;
return eventNumber;
public class CarlyEvent
public final static int pricePerGuest ;
public final static int largeGroup ;
private String eventNum;
private int numGuest;
private int price;
event number
public String getEventNumberget
return eventNum;
public void setEventNumberString eventNumset
this.eventNum eventNum;
guests
public int getGuestget
return numGuest;
public void setGuestint numGuestset
this.numGuest numGuest;
price numGuest pricePerGuest;
public int getPriceget
return price;
public class CarlyEventDemo
public static void mainString args
variables
int price;
int numOfGuests;
String eventNum;
objects
CarlyEvent event new CarlyEvent;
Carly.motto;
eventNum Carly.getEventNum;
numOfGuests Carly.numGuests;
Carly.pricenumOfGuests;
event.setEventNumbereventNum;
event.setGuestnumOfGuests;
System.out.printlnEvent number: event.getEventNumber
Number of guests: event.getGuest;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
