Skip to content

Commit 0725bb6

Browse files
committed
Started Case Study
1 parent 278d5d4 commit 0725bb6

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

Carlys Catering/src/CarlysEventPriceWithMethods.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static void main(String[] args)
3131
{
3232
getGuests();
3333
displayMotto();
34-
//displayEvent(guests);
34+
displayEvent(guests);
3535
}
3636
public static int getGuests()
3737
{
@@ -44,16 +44,13 @@ public static String getEventNumber()
4444
getEventNumber();
4545
return getEventNumber();
4646
}
47-
public static void displayEvent(Event object)
47+
public static void displayEvent(int guests)
4848
{
4949
boolean isLargeEvent = (guests > 49);
50-
totalBill = guests * PRICE_PER_GUEST;
51-
52-
System.out.println("Number of guests attending: " + guests);
50+
System.out.println("Number of guests attending: " + getGuests());
5351
System.out.println("Price Per Guest: " + PRICE_PER_GUEST);
5452
System.out.println("Total Bill: " + totalBill);
5553
System.out.println("Is this a large event: " + isLargeEvent);
56-
5754
}
5855
public static void displayMotto()
5956
{

Carlys Catering/src/Event.java

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,15 @@
2020
*/
2121
public class Event
2222
{
23-
public static final double PRICE_PER_GUEST = 35.00;
23+
public static double pricePerGuestHigh = 35.00;
24+
public static double pricePerGuestLow = 32.00;
2425
public static final int LARGE_EVENT_MAX = 50;
2526
private String eventNumber;
2627
private int guests;
27-
private double totalBill;
28-
29-
//TODO and fields, constructors, and methods;
30-
public static void main(String[] args)
31-
{
32-
//TODO add methods;
33-
}
28+
private double pricePerEvent;
29+
30+
31+
3432
public void setEventNumber()
3533
{
3634
Scanner enter = new Scanner(System.in);
@@ -42,18 +40,26 @@ public void setGuests()
4240
Scanner enter = new Scanner(System.in);
4341
System.out.println("Enter the number of guest attending ");
4442
guests = enter.nextInt();
45-
totalBill = guests * PRICE_PER_GUEST;
4643
}
47-
public String getEventNumber()
44+
public boolean isLargeEvent()
4845
{
49-
return eventNumber;
46+
if (guests >= LARGE_EVENT_MAX)
47+
{
48+
return true;
49+
}
50+
else if (guests < LARGE_EVENT_MAX)
51+
{
52+
return false;
53+
}
54+
return isLargeEvent();
5055
}
51-
public int getGuests()
56+
57+
public String getEventNumber(int guests)
5258
{
53-
return guests;
59+
return eventNumber;
5460
}
55-
public double getPrice()
61+
public int getGuests(boolean largeEvent)
5662
{
57-
return totalBill;
63+
return guests;
5864
}
5965
}

Carlys Catering/src/EventDemo.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,12 @@
2222
*/
2323
public class EventDemo
2424
{
25-
2625
public static void main(String[] args)
2726
{
2827
Event test001 = new Event();
2928
test001.setEventNumber();
3029
test001.setGuests();
31-
test001.getPrice();
3230
CarlysEventPriceWithMethods.displayMotto();
33-
CarlysEventPriceWithMethods.displayEvent(test001);
34-
31+
CarlysEventPriceWithMethods.displayEvent(Integer.parseInt(test001.getEventNumber(test001.getGuests(test001.isLargeEvent(test001.getPrice())))));
3532
}
3633
}

0 commit comments

Comments
 (0)