From 3e8ac06750a1e2a5cc46977b3c0f3a3a8c73b973 Mon Sep 17 00:00:00 2001 From: Benjamin Le Date: Tue, 21 Nov 2023 21:14:53 -0800 Subject: [PATCH 01/10] First commit --- .../BenjaminLe/airbnb/BookingService.java | 8 ++ .../BenjaminLe/airbnb/BookingServiceImpl.java | 20 ++++ .../BenjaminLe/airbnb/DiscountedHotel.java | 15 +++ .../partA/BenjaminLe/airbnb/Hotel.java | 14 +++ .../partA/BenjaminLe/airbnb/Main.java | 23 ++++ .../partA/BenjaminLe/airbnb/hotelPrices.java | 11 ++ .../partA/BenjaminLe/doordash/Customer.java | 18 ++++ .../BenjaminLe/doordash/DeliveryService.java | 7 ++ .../BenjaminLe/doordash/FoodDelivery.java | 13 +++ .../partA/BenjaminLe/doordash/Restaurant.java | 14 +++ .../BenjaminLe/doordash/TrackingService.java | 8 ++ .../BenjaminLe/doordash/trackPackages.java | 5 + .../partA/BenjaminLe/facebook/Post1.java | 8 ++ .../partA/BenjaminLe/facebook/postImages.java | 36 +++++++ .../partA/BenjaminLe/facebook/postText.java | 35 ++++++ .../partA/BenjaminLe/facebook/postVideo.java | 39 +++++++ .../partA/BenjaminLe/paypal/Account.java | 13 +++ .../partA/BenjaminLe/paypal/Main.java | 11 ++ .../BenjaminLe/paypal/PayPalBarrier.java | 5 + .../BenjaminLe/paypal/PayPalGateway.java | 13 +++ .../BenjaminLe/paypal/PaymentProcessor.java | 18 ++++ .../partA/BenjaminLe/uber/Main.java | 19 ++++ .../partA/BenjaminLe/uber/RideManager.java | 100 ++++++++++++++++++ .../partA/BenjaminLe/uber/carRideCost.java | 5 + 24 files changed, 458 insertions(+) create mode 100644 homework/src/HW1/submissions/partA/BenjaminLe/airbnb/BookingService.java create mode 100644 homework/src/HW1/submissions/partA/BenjaminLe/airbnb/BookingServiceImpl.java create mode 100644 homework/src/HW1/submissions/partA/BenjaminLe/airbnb/DiscountedHotel.java create mode 100644 homework/src/HW1/submissions/partA/BenjaminLe/airbnb/Hotel.java create mode 100644 homework/src/HW1/submissions/partA/BenjaminLe/airbnb/Main.java create mode 100644 homework/src/HW1/submissions/partA/BenjaminLe/airbnb/hotelPrices.java create mode 100644 homework/src/HW1/submissions/partA/BenjaminLe/doordash/Customer.java create mode 100644 homework/src/HW1/submissions/partA/BenjaminLe/doordash/DeliveryService.java create mode 100644 homework/src/HW1/submissions/partA/BenjaminLe/doordash/FoodDelivery.java create mode 100644 homework/src/HW1/submissions/partA/BenjaminLe/doordash/Restaurant.java create mode 100644 homework/src/HW1/submissions/partA/BenjaminLe/doordash/TrackingService.java create mode 100644 homework/src/HW1/submissions/partA/BenjaminLe/doordash/trackPackages.java create mode 100644 homework/src/HW1/submissions/partA/BenjaminLe/facebook/Post1.java create mode 100644 homework/src/HW1/submissions/partA/BenjaminLe/facebook/postImages.java create mode 100644 homework/src/HW1/submissions/partA/BenjaminLe/facebook/postText.java create mode 100644 homework/src/HW1/submissions/partA/BenjaminLe/facebook/postVideo.java create mode 100644 homework/src/HW1/submissions/partA/BenjaminLe/paypal/Account.java create mode 100644 homework/src/HW1/submissions/partA/BenjaminLe/paypal/Main.java create mode 100644 homework/src/HW1/submissions/partA/BenjaminLe/paypal/PayPalBarrier.java create mode 100644 homework/src/HW1/submissions/partA/BenjaminLe/paypal/PayPalGateway.java create mode 100644 homework/src/HW1/submissions/partA/BenjaminLe/paypal/PaymentProcessor.java create mode 100644 homework/src/HW1/submissions/partA/BenjaminLe/uber/Main.java create mode 100644 homework/src/HW1/submissions/partA/BenjaminLe/uber/RideManager.java create mode 100644 homework/src/HW1/submissions/partA/BenjaminLe/uber/carRideCost.java diff --git a/homework/src/HW1/submissions/partA/BenjaminLe/airbnb/BookingService.java b/homework/src/HW1/submissions/partA/BenjaminLe/airbnb/BookingService.java new file mode 100644 index 0000000..6982da2 --- /dev/null +++ b/homework/src/HW1/submissions/partA/BenjaminLe/airbnb/BookingService.java @@ -0,0 +1,8 @@ +package airbnb; + +public interface BookingService { + int calculateTotalPrice(Hotel hotel, int numberOfNights); + + double totalBill(int tip); +} + diff --git a/homework/src/HW1/submissions/partA/BenjaminLe/airbnb/BookingServiceImpl.java b/homework/src/HW1/submissions/partA/BenjaminLe/airbnb/BookingServiceImpl.java new file mode 100644 index 0000000..aeb71da --- /dev/null +++ b/homework/src/HW1/submissions/partA/BenjaminLe/airbnb/BookingServiceImpl.java @@ -0,0 +1,20 @@ +package airbnb; + +public class BookingServiceImpl implements BookingService { + int totalCost = 0; + + @Override + public int calculateTotalPrice(Hotel hotel, int numberOfNights) { + totalCost = 0; + int totalPrice = hotel.calculateTotalPrice(numberOfNights); + totalCost += totalPrice; + return totalPrice; + } + + @Override + public double totalBill(int tip) { + //total cost + tax (because 7.25% is california's hotel tax) + tip amount you want to put) + return totalCost + (totalCost*0.0725) + tip; + } + +} \ No newline at end of file diff --git a/homework/src/HW1/submissions/partA/BenjaminLe/airbnb/DiscountedHotel.java b/homework/src/HW1/submissions/partA/BenjaminLe/airbnb/DiscountedHotel.java new file mode 100644 index 0000000..3cc25aa --- /dev/null +++ b/homework/src/HW1/submissions/partA/BenjaminLe/airbnb/DiscountedHotel.java @@ -0,0 +1,15 @@ +package airbnb; + +public class DiscountedHotel extends Hotel { + + @Override + public int calculateTotalPrice(int numberOfNights) { + + /*by turning the super method into numberOfNights * 100 + * we ensure that this method still functions by itself even + * if the hotel class were to disappear since we've overriden + * its functionality + */ + return numberOfNights * 100 - 50; + } +} \ No newline at end of file diff --git a/homework/src/HW1/submissions/partA/BenjaminLe/airbnb/Hotel.java b/homework/src/HW1/submissions/partA/BenjaminLe/airbnb/Hotel.java new file mode 100644 index 0000000..7e28862 --- /dev/null +++ b/homework/src/HW1/submissions/partA/BenjaminLe/airbnb/Hotel.java @@ -0,0 +1,14 @@ +package airbnb; + +public class Hotel implements hotelPrices{ + + + + @Override + public int calculateTotalPrice(int numberOfNights) { + + return numberOfNights * 100; + } + + +} \ No newline at end of file diff --git a/homework/src/HW1/submissions/partA/BenjaminLe/airbnb/Main.java b/homework/src/HW1/submissions/partA/BenjaminLe/airbnb/Main.java new file mode 100644 index 0000000..4608992 --- /dev/null +++ b/homework/src/HW1/submissions/partA/BenjaminLe/airbnb/Main.java @@ -0,0 +1,23 @@ +package airbnb; + + +public class Main { + public static void main(String[] args) { + Hotel regularHotel = new Hotel(); + DiscountedHotel discountedHotel = new DiscountedHotel(); + + BookingService bookingService = new BookingServiceImpl(); + int regularHotelTotalPrice = bookingService.calculateTotalPrice(regularHotel, 3); + double regAndTip = bookingService.totalBill(20); + System.out.println("Regular Hotel Total Price: $" + regularHotelTotalPrice); + System.out.println("Regular Hotel Price WITH TAX & TIP: $" + regAndTip); + + int discountedHotelTotalPrice = bookingService.calculateTotalPrice(discountedHotel, 3); + + double disAndTip = bookingService.totalBill(30); + + System.out.println("Discounted Hotel Total Price: $" + discountedHotelTotalPrice); + System.out.println("Discounted Hotel Price WITH TAX & TIP: $" + disAndTip); + + } +} diff --git a/homework/src/HW1/submissions/partA/BenjaminLe/airbnb/hotelPrices.java b/homework/src/HW1/submissions/partA/BenjaminLe/airbnb/hotelPrices.java new file mode 100644 index 0000000..8eb0a1f --- /dev/null +++ b/homework/src/HW1/submissions/partA/BenjaminLe/airbnb/hotelPrices.java @@ -0,0 +1,11 @@ +package airbnb; + +public interface hotelPrices { + /*this way we enforce the open/closed principle since + * the initial calculateTotalPrice is closed from modification + * but open to modification if we want to find out the prices from + * different hotel types. + */ + int calculateTotalPrice(int numberOfNights); + +} \ No newline at end of file diff --git a/homework/src/HW1/submissions/partA/BenjaminLe/doordash/Customer.java b/homework/src/HW1/submissions/partA/BenjaminLe/doordash/Customer.java new file mode 100644 index 0000000..44be870 --- /dev/null +++ b/homework/src/HW1/submissions/partA/BenjaminLe/doordash/Customer.java @@ -0,0 +1,18 @@ +package doordash; + +public class Customer { + private String name; + private String address; + + public Customer(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public String getAddress() { + return address; + } +} diff --git a/homework/src/HW1/submissions/partA/BenjaminLe/doordash/DeliveryService.java b/homework/src/HW1/submissions/partA/BenjaminLe/doordash/DeliveryService.java new file mode 100644 index 0000000..e311bfe --- /dev/null +++ b/homework/src/HW1/submissions/partA/BenjaminLe/doordash/DeliveryService.java @@ -0,0 +1,7 @@ +package doordash; + +public interface DeliveryService { + void deliverFood(Restaurant restaurant, Customer customer); + void uberEats(Restaurant restaurant, Customer customer); + +} diff --git a/homework/src/HW1/submissions/partA/BenjaminLe/doordash/FoodDelivery.java b/homework/src/HW1/submissions/partA/BenjaminLe/doordash/FoodDelivery.java new file mode 100644 index 0000000..b607409 --- /dev/null +++ b/homework/src/HW1/submissions/partA/BenjaminLe/doordash/FoodDelivery.java @@ -0,0 +1,13 @@ +package doordash; + +public class FoodDelivery implements DeliveryService { + @Override + public void deliverFood(Restaurant restaurant, Customer customer) { + System.out.println("Food delivered from " + restaurant.getName() + " to " + customer.getName()); + } + public void uberEats(Restaurant restaurant, Customer customer){ + System.out.println("" + customer.getName() + "food order needs to be delivered from " + restaurant.getName() + " to " + customer.getAddress()); + } + + +} \ No newline at end of file diff --git a/homework/src/HW1/submissions/partA/BenjaminLe/doordash/Restaurant.java b/homework/src/HW1/submissions/partA/BenjaminLe/doordash/Restaurant.java new file mode 100644 index 0000000..6523484 --- /dev/null +++ b/homework/src/HW1/submissions/partA/BenjaminLe/doordash/Restaurant.java @@ -0,0 +1,14 @@ +package doordash; + +public class Restaurant { + private String name; + + public Restaurant(String name) { + this.name = name; + } + + public String getName() { + return name; + } +} + diff --git a/homework/src/HW1/submissions/partA/BenjaminLe/doordash/TrackingService.java b/homework/src/HW1/submissions/partA/BenjaminLe/doordash/TrackingService.java new file mode 100644 index 0000000..2fe3ad9 --- /dev/null +++ b/homework/src/HW1/submissions/partA/BenjaminLe/doordash/TrackingService.java @@ -0,0 +1,8 @@ +package doordash; + +public class TrackingService implements trackPackages { + @Override + public void trackPackage(String trackingNumber) { + System.out.println("Package with tracking number " + trackingNumber + " is being tracked."); + } +} diff --git a/homework/src/HW1/submissions/partA/BenjaminLe/doordash/trackPackages.java b/homework/src/HW1/submissions/partA/BenjaminLe/doordash/trackPackages.java new file mode 100644 index 0000000..7731f4b --- /dev/null +++ b/homework/src/HW1/submissions/partA/BenjaminLe/doordash/trackPackages.java @@ -0,0 +1,5 @@ +package doordash; + +public interface trackPackages { + void trackPackage(String trackingNumber); +} diff --git a/homework/src/HW1/submissions/partA/BenjaminLe/facebook/Post1.java b/homework/src/HW1/submissions/partA/BenjaminLe/facebook/Post1.java new file mode 100644 index 0000000..afb492d --- /dev/null +++ b/homework/src/HW1/submissions/partA/BenjaminLe/facebook/Post1.java @@ -0,0 +1,8 @@ +package facebook; + +//This was the original post class, that was implemented for our "Facebook". + +public interface Post1 { + + void display(); +} diff --git a/homework/src/HW1/submissions/partA/BenjaminLe/facebook/postImages.java b/homework/src/HW1/submissions/partA/BenjaminLe/facebook/postImages.java new file mode 100644 index 0000000..ba67fbb --- /dev/null +++ b/homework/src/HW1/submissions/partA/BenjaminLe/facebook/postImages.java @@ -0,0 +1,36 @@ +package facebook; + +public class postImages implements Post1{ + + private String imageUrl; + + private boolean isImage; + + public String getImageUrl() { + return imageUrl; + } + + public void setImageUrl(String imageUrl) { + this.imageUrl = imageUrl; + } + + public boolean isImage() { + return isImage; + } + + public void setImage(boolean image) { + isImage = image; + } + + public postImages(String imageUrl, boolean isImage) { + if(isImage) { + this.imageUrl = imageUrl; + this.isImage = true; + } + } + + public void display() { + System.out.println(imageUrl); + } + +} diff --git a/homework/src/HW1/submissions/partA/BenjaminLe/facebook/postText.java b/homework/src/HW1/submissions/partA/BenjaminLe/facebook/postText.java new file mode 100644 index 0000000..87eb769 --- /dev/null +++ b/homework/src/HW1/submissions/partA/BenjaminLe/facebook/postText.java @@ -0,0 +1,35 @@ +package facebook; + + +//This is the new post class, that was implemented for our "Facebook" to help support images and videos. + +public class postText implements Post1 { + + private String text; + + + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + + + + public postText(String text) { + this.text = text; + } + + + void displayText() { + System.out.println(text); + } + + public void display() { + System.out.println(text); + } +} diff --git a/homework/src/HW1/submissions/partA/BenjaminLe/facebook/postVideo.java b/homework/src/HW1/submissions/partA/BenjaminLe/facebook/postVideo.java new file mode 100644 index 0000000..f8309ff --- /dev/null +++ b/homework/src/HW1/submissions/partA/BenjaminLe/facebook/postVideo.java @@ -0,0 +1,39 @@ +package facebook; + +public class postVideo implements Post1 { + + private String videoUrl; + + private boolean isVideo; + + public String getVideoUrl() { + return videoUrl; + } + + public void setVideoUrl(String videoUrl) { + this.videoUrl = videoUrl; + } + + + public boolean isVideo() { + return isVideo; + } + + + public void setVideo(boolean video) { + isVideo = video; + } + + + public postVideo(String videoUrl, boolean isVideo){ + if(isVideo) { + this.videoUrl = videoUrl; + this.isVideo = true; + } + } + + public void display() { + System.out.println(videoUrl); + } + +} diff --git a/homework/src/HW1/submissions/partA/BenjaminLe/paypal/Account.java b/homework/src/HW1/submissions/partA/BenjaminLe/paypal/Account.java new file mode 100644 index 0000000..e9408db --- /dev/null +++ b/homework/src/HW1/submissions/partA/BenjaminLe/paypal/Account.java @@ -0,0 +1,13 @@ +package paypal; + +public class Account { + private String accountID; + + public Account(String accountID) { + this.accountID = accountID; + } + + public String getAccountID() { + return accountID; + } +} diff --git a/homework/src/HW1/submissions/partA/BenjaminLe/paypal/Main.java b/homework/src/HW1/submissions/partA/BenjaminLe/paypal/Main.java new file mode 100644 index 0000000..31e056b --- /dev/null +++ b/homework/src/HW1/submissions/partA/BenjaminLe/paypal/Main.java @@ -0,0 +1,11 @@ +package paypal; + +public class Main { + public static void main(String[] args) { + PaymentProcessor paymentProcessor = new PaymentProcessor(); + Account account = new Account("1"); + Account account2 = new Account("2"); + paymentProcessor.processPayment(account,100.0); + paymentProcessor.requestRefund(account2,50.0); + } +} diff --git a/homework/src/HW1/submissions/partA/BenjaminLe/paypal/PayPalBarrier.java b/homework/src/HW1/submissions/partA/BenjaminLe/paypal/PayPalBarrier.java new file mode 100644 index 0000000..08e4c7a --- /dev/null +++ b/homework/src/HW1/submissions/partA/BenjaminLe/paypal/PayPalBarrier.java @@ -0,0 +1,5 @@ +package paypal; + +public class PayPalBarrier { + +} diff --git a/homework/src/HW1/submissions/partA/BenjaminLe/paypal/PayPalGateway.java b/homework/src/HW1/submissions/partA/BenjaminLe/paypal/PayPalGateway.java new file mode 100644 index 0000000..2f2ecd8 --- /dev/null +++ b/homework/src/HW1/submissions/partA/BenjaminLe/paypal/PayPalGateway.java @@ -0,0 +1,13 @@ +package paypal; + +public class PayPalGateway extends PayPalBarrier{ + + + public void processPayment(Account account, double amount) { + System.out.println("Processing payment of $" + amount + " for account " + account.getAccountID() + " using PayPal."); + } + + public void requestRefund(Account account, double amount) { + System.out.println("Requesting refund of $" + amount + " from account " + account.getAccountID() + " using PayPal."); + } +} diff --git a/homework/src/HW1/submissions/partA/BenjaminLe/paypal/PaymentProcessor.java b/homework/src/HW1/submissions/partA/BenjaminLe/paypal/PaymentProcessor.java new file mode 100644 index 0000000..2739863 --- /dev/null +++ b/homework/src/HW1/submissions/partA/BenjaminLe/paypal/PaymentProcessor.java @@ -0,0 +1,18 @@ +package paypal; + +public class PaymentProcessor extends PayPalBarrier{ + private PayPalGateway payPalGateway; + + PaymentProcessor() { + this.payPalGateway = new PayPalGateway(); + } + + public void processPayment(Account account, double amount) { + payPalGateway.processPayment(account,amount); + } + + public void requestRefund(Account account, double amount) { + payPalGateway.requestRefund(account,amount); + } + +} \ No newline at end of file diff --git a/homework/src/HW1/submissions/partA/BenjaminLe/uber/Main.java b/homework/src/HW1/submissions/partA/BenjaminLe/uber/Main.java new file mode 100644 index 0000000..58f8808 --- /dev/null +++ b/homework/src/HW1/submissions/partA/BenjaminLe/uber/Main.java @@ -0,0 +1,19 @@ +package uber; + +public class Main { + public static void main(String[] args) { + Ride ride = new Ride(1,1); + User user = new User(); + user.setUsername("john_doe"); + + RideManager rideManager = new RideManager(); + + deluxeRideManager delRideManager = new deluxeRideManager(); + + double fare = rideManager.calculateRideFare(ride); + double deluxeFare = delRideManager.calculateRideFare(ride); + + rideManager.sendNotification(user, "Your ride fare is: $" + fare); + delRideManager.sendNotification(user, "Your deluxe ride fare is: $" + deluxeFare); + } +} \ No newline at end of file diff --git a/homework/src/HW1/submissions/partA/BenjaminLe/uber/RideManager.java b/homework/src/HW1/submissions/partA/BenjaminLe/uber/RideManager.java new file mode 100644 index 0000000..103a95c --- /dev/null +++ b/homework/src/HW1/submissions/partA/BenjaminLe/uber/RideManager.java @@ -0,0 +1,100 @@ +package uber; + +class RideManager implements carRideCost { + private final double BASE_FARE = 5.0; // Base fare in dollars + private final double PER_MILE_RATE = 2.0; // Fare per mile in dollars + private final double PER_MINUTE_RATE = 0.5; // Fare per minute in dollars + + public double calculateRideFare(Ride ride) { + double distanceInMiles = ride.getDistanceInMiles(); + int durationInMinutes = ride.getDurationInMinutes(); + + // Calculate fare based on distance and time + double distanceFare = distanceInMiles * PER_MILE_RATE; + double timeFare = durationInMinutes * PER_MINUTE_RATE; + + // Calculate total fare including base fare + double totalFare = BASE_FARE + distanceFare + timeFare; + + return totalFare; + } + + void sendNotification(User user, String message) { + // Code for sending notifications to the user + System.out.println("Notification sent to user: " + user.getUsername() + " - " + message); + } +} + + +class deluxeRideManager implements carRideCost { + private final double BASE_FARE = 10.0; // Base fare in dollars + private final double PER_MILE_RATE = 4.0; // Fare per mile in dollars + private final double PER_MINUTE_RATE = 1.0; // Fare per minute in dollars + + //deluxe just cost a bunch more money but since we're implementing from carRideCost + // ->I'm still following the open-closed principle since I don't have ot modify the RideManager Class anymore + + public double calculateRideFare(Ride ride) { + double distanceInMiles = ride.getDistanceInMiles(); + int durationInMinutes = ride.getDurationInMinutes(); + + // Calculate fare based on distance and time + double distanceFare = distanceInMiles * PER_MILE_RATE; + double timeFare = durationInMinutes * PER_MINUTE_RATE; + + // Calculate total fare including base fare + double totalFare = BASE_FARE + distanceFare + timeFare; + + return totalFare*2; + } + + void sendNotification(User user, String message) { + // Code for sending notifications to the user + System.out.println("Notification sent to user: " + user.getUsername() + " - " + message); + } +} + + +class Ride { + private double distanceInMiles; + private int durationInMinutes; + + public Ride(double distanceInMiles, int durationInMinutes) { + this.distanceInMiles = distanceInMiles; + this.durationInMinutes = durationInMinutes; + } + + public double getDistanceInMiles() { + return distanceInMiles; + } + + public void setDistanceInMiles(double distanceInMiles) { + this.distanceInMiles = distanceInMiles; + } + + public int getDurationInMinutes() { + return durationInMinutes; + } + + public void setDurationInMinutes(int durationInMinutes) { + this.durationInMinutes = durationInMinutes; + } + +} + +class User { + // User details + private String username; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + +} + + diff --git a/homework/src/HW1/submissions/partA/BenjaminLe/uber/carRideCost.java b/homework/src/HW1/submissions/partA/BenjaminLe/uber/carRideCost.java new file mode 100644 index 0000000..46bb568 --- /dev/null +++ b/homework/src/HW1/submissions/partA/BenjaminLe/uber/carRideCost.java @@ -0,0 +1,5 @@ +package uber; + +public interface carRideCost { + double calculateRideFare(Ride ride); +} From 1043e8f8db31a1ac72e1eb5114165f9a9c49583d Mon Sep 17 00:00:00 2001 From: bluegoat2 <144287437+bluegoat2@users.noreply.github.com> Date: Tue, 21 Nov 2023 23:21:47 -0800 Subject: [PATCH 02/10] Create BenjaminLe.txt --- homework/src/HW1/submissions/partB/BenjaminLe.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 homework/src/HW1/submissions/partB/BenjaminLe.txt diff --git a/homework/src/HW1/submissions/partB/BenjaminLe.txt b/homework/src/HW1/submissions/partB/BenjaminLe.txt new file mode 100644 index 0000000..9691d34 --- /dev/null +++ b/homework/src/HW1/submissions/partB/BenjaminLe.txt @@ -0,0 +1 @@ +Link to part B: https://github.com/bluegoat2/CS151HW1PartB From 31fb5435f00a066d9eb0a8e860ad75fc9802566f Mon Sep 17 00:00:00 2001 From: bluegoat2 <144287437+bluegoat2@users.noreply.github.com> Date: Tue, 21 Nov 2023 23:28:50 -0800 Subject: [PATCH 03/10] Create README.md --- .../submissions/partA/BenjaminLe/README.md | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 homework/src/HW1/submissions/partA/BenjaminLe/README.md diff --git a/homework/src/HW1/submissions/partA/BenjaminLe/README.md b/homework/src/HW1/submissions/partA/BenjaminLe/README.md new file mode 100644 index 0000000..2b85d0f --- /dev/null +++ b/homework/src/HW1/submissions/partA/BenjaminLe/README.md @@ -0,0 +1,93 @@ +#Problem: Airbnb + +## pt.1 What SOLID(s) principle is being violated? + +Liskov Substitution Principle: Discounted Hotel is unable to replace Hotel because it uses the super. method and if the Hotel class is gone then super. won't have anything to inherit thus it no longer works +Open Closed Principle: I have to extend and modify the hotel class every time I want to add a different house to the airbnb. + +## pt.2 How do you fix the identified issues above? + +Change super.calculateTotalPrice(numberOfNights) to numberOfNights * 100. This way even if Hotel disappears we still have + +Create an interface that holds the calculateTotalPrice() function so that different hotel types can implement it. This way the prices of different hotels can still be customized (open) while the original code cannot be modified (closed). + +## pt.3 Additional Functionality + +Allows users to see how much the total bill is with California tax and a tip amount of their choice. + + + +#Problem: DoorDash + +## pt.1 What SOLID(s) principle is being violated? + +Interface Separation Principle: We only need to deliver food and not track packages so it's necessary to force users to implement a trackPackage function +Single Responsibility Principle: FoodDeliveryAndTrackingService class has 2 different responsibilities: food delivery and tracking packages + + +## pt.2 How do you fix the identified issues above? + +Move the “track package” function from the DeliveryService interface into a different interface +Split the FoodDeliveryAndTrackingService into 2 different classes with 1 responsibility each: Class FoodDelivery and Class Tracking Service + +## pt.3 Additional Functionality +Allows users to see what orders still need to be delivered to a specific address of the customer. + + + + + +#Problem: Facebook + +## pt.1 What SOLID(s) principle is being violated? + +Single Responsibility Principle: Post2 has too many responsibilities working with images, videos, text, etc + + +## pt.2 How do you fix the identified issues above? + +Split the Post2 class into 3 different classes: images, text, videos + +## pt.3 Additional Functionality + +Turned Post1 into an interface to ensure that if we want to create different posts in the future like posting figs then we can easily implement it. Along with that I added a “display()” function for each class that just displays the url of each image/video. This is to set up for future functionality when we have the code to import and display the actual image/video. + + +#Problem: PayPal + +## pt.1 What SOLID(s) principle is being violated? + +Dependency Inversion Principle: PayPalProcessor is a high level module that's dependent on PayPalGateway which is a low level module + +- PaymentProcessor is a high-level module because it orchestrates the payment processing logic and is more abstract + +- PayPalGateway is a lower-level module because it handles the specific implementation details of processing payments via PayPal. + + +## pt.2 How do you fix the identified issues above? + +To align with the Dependency Inversion Principle the high-level module class should be dependent on an interface or an abstract class rather than a concrete lower level module class like PayPalGateway. To fix this I created an interface called PayPalBarrier for both of them to implement. + +## pt.3 Additional Functionality + +You can now request a refund of a specific amount from a specific account + + + + +#Problem: Uber + +## pt.1 What SOLID(s) principle is being violated? + +Open-Closed Principle: the RideManager class only calculates the rideFare for a normal Ride class. If I wanted to ride in a deluxe uber then it might cost more. However, in order to calculate the ride fare I would have to modify the RideManager class directly which violates the Open-Closed principle. + + +## pt.2 How do you fix the identified issues above? +I created an interface to hold the calculateRideFare function. This way if I want to find out the cost of a different kind of uber like a deluxe uber then I can easily implement it without having to modify the initial RideManager class. + +## pt.3 Additional Functionality + +There’s a new RideManagerDeluxe class that allows you to calculate the ride fare of what a deluxe uber would cost with the same distance in miles and duration in minutes. + + + From 3bcd1f0b1680227ca95760e3bde985c0f79dfff9 Mon Sep 17 00:00:00 2001 From: bluegoat2 <144287437+bluegoat2@users.noreply.github.com> Date: Tue, 21 Nov 2023 23:29:35 -0800 Subject: [PATCH 04/10] Update README.md --- .../HW1/submissions/partA/BenjaminLe/README.md | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/homework/src/HW1/submissions/partA/BenjaminLe/README.md b/homework/src/HW1/submissions/partA/BenjaminLe/README.md index 2b85d0f..3f36e4b 100644 --- a/homework/src/HW1/submissions/partA/BenjaminLe/README.md +++ b/homework/src/HW1/submissions/partA/BenjaminLe/README.md @@ -1,4 +1,4 @@ -#Problem: Airbnb +# Problem: Airbnb ## pt.1 What SOLID(s) principle is being violated? @@ -16,8 +16,7 @@ Create an interface that holds the calculateTotalPrice() function so that differ Allows users to see how much the total bill is with California tax and a tip amount of their choice. - -#Problem: DoorDash +# Problem: DoorDash ## pt.1 What SOLID(s) principle is being violated? @@ -34,10 +33,7 @@ Split the FoodDeliveryAndTrackingService into 2 different classes with 1 respons Allows users to see what orders still need to be delivered to a specific address of the customer. - - - -#Problem: Facebook +# Problem: Facebook ## pt.1 What SOLID(s) principle is being violated? @@ -53,7 +49,7 @@ Split the Post2 class into 3 different classes: images, text, videos Turned Post1 into an interface to ensure that if we want to create different posts in the future like posting figs then we can easily implement it. Along with that I added a “display()” function for each class that just displays the url of each image/video. This is to set up for future functionality when we have the code to import and display the actual image/video. -#Problem: PayPal +# Problem: PayPal ## pt.1 What SOLID(s) principle is being violated? @@ -73,9 +69,7 @@ To align with the Dependency Inversion Principle the high-level module class sho You can now request a refund of a specific amount from a specific account - - -#Problem: Uber +# Problem: Uber ## pt.1 What SOLID(s) principle is being violated? From 5a2dfbb32b413173078b9d7f26c2738b39f0a738 Mon Sep 17 00:00:00 2001 From: bluegoat2 <144287437+bluegoat2@users.noreply.github.com> Date: Tue, 21 Nov 2023 23:30:02 -0800 Subject: [PATCH 05/10] Update README.md --- homework/src/HW1/submissions/partA/BenjaminLe/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homework/src/HW1/submissions/partA/BenjaminLe/README.md b/homework/src/HW1/submissions/partA/BenjaminLe/README.md index 3f36e4b..a80d83b 100644 --- a/homework/src/HW1/submissions/partA/BenjaminLe/README.md +++ b/homework/src/HW1/submissions/partA/BenjaminLe/README.md @@ -2,8 +2,8 @@ ## pt.1 What SOLID(s) principle is being violated? -Liskov Substitution Principle: Discounted Hotel is unable to replace Hotel because it uses the super. method and if the Hotel class is gone then super. won't have anything to inherit thus it no longer works -Open Closed Principle: I have to extend and modify the hotel class every time I want to add a different house to the airbnb. +- Liskov Substitution Principle: Discounted Hotel is unable to replace Hotel because it uses the super. method and if the Hotel class is gone then super. won't have anything to inherit thus it no longer works +- Open Closed Principle: I have to extend and modify the hotel class every time I want to add a different house to the airbnb. ## pt.2 How do you fix the identified issues above? From b0e6f748e03e6bbfe31ca06fc5127f11c757818b Mon Sep 17 00:00:00 2001 From: bluegoat2 <144287437+bluegoat2@users.noreply.github.com> Date: Tue, 21 Nov 2023 23:31:24 -0800 Subject: [PATCH 06/10] Update README.md --- .../submissions/partA/BenjaminLe/README.md | 39 +++++++++---------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/homework/src/HW1/submissions/partA/BenjaminLe/README.md b/homework/src/HW1/submissions/partA/BenjaminLe/README.md index a80d83b..64722e2 100644 --- a/homework/src/HW1/submissions/partA/BenjaminLe/README.md +++ b/homework/src/HW1/submissions/partA/BenjaminLe/README.md @@ -7,81 +7,80 @@ ## pt.2 How do you fix the identified issues above? -Change super.calculateTotalPrice(numberOfNights) to numberOfNights * 100. This way even if Hotel disappears we still have +- Change super.calculateTotalPrice(numberOfNights) to numberOfNights * 100. This way even if Hotel disappears we still have -Create an interface that holds the calculateTotalPrice() function so that different hotel types can implement it. This way the prices of different hotels can still be customized (open) while the original code cannot be modified (closed). +- Create an interface that holds the calculateTotalPrice() function so that different hotel types can implement it. This way the prices of different hotels can still be customized (open) while the original code cannot be modified (closed). ## pt.3 Additional Functionality -Allows users to see how much the total bill is with California tax and a tip amount of their choice. +- Allows users to see how much the total bill is with California tax and a tip amount of their choice. # Problem: DoorDash ## pt.1 What SOLID(s) principle is being violated? -Interface Separation Principle: We only need to deliver food and not track packages so it's necessary to force users to implement a trackPackage function -Single Responsibility Principle: FoodDeliveryAndTrackingService class has 2 different responsibilities: food delivery and tracking packages +- Interface Separation Principle: We only need to deliver food and not track packages so it's necessary to force users to implement a trackPackage function +- Single Responsibility Principle: FoodDeliveryAndTrackingService class has 2 different responsibilities: food delivery and tracking packages ## pt.2 How do you fix the identified issues above? -Move the “track package” function from the DeliveryService interface into a different interface -Split the FoodDeliveryAndTrackingService into 2 different classes with 1 responsibility each: Class FoodDelivery and Class Tracking Service +- Move the “track package” function from the DeliveryService interface into a different interface +- Split the FoodDeliveryAndTrackingService into 2 different classes with 1 responsibility each: Class FoodDelivery and Class Tracking Service ## pt.3 Additional Functionality -Allows users to see what orders still need to be delivered to a specific address of the customer. +- Allows users to see what orders still need to be delivered to a specific address of the customer. # Problem: Facebook ## pt.1 What SOLID(s) principle is being violated? -Single Responsibility Principle: Post2 has too many responsibilities working with images, videos, text, etc - +- Single Responsibility Principle: Post2 has too many responsibilities working with images, videos, text, etc ## pt.2 How do you fix the identified issues above? -Split the Post2 class into 3 different classes: images, text, videos +- Split the Post2 class into 3 different classes: images, text, videos ## pt.3 Additional Functionality -Turned Post1 into an interface to ensure that if we want to create different posts in the future like posting figs then we can easily implement it. Along with that I added a “display()” function for each class that just displays the url of each image/video. This is to set up for future functionality when we have the code to import and display the actual image/video. +- Turned Post1 into an interface to ensure that if we want to create different posts in the future like posting gifs then we can easily implement it. Along with that I added a “display()” function for each class that just displays the url of each image/video. This is to set up for future functionality when we have the code to import and display the actual image/video. # Problem: PayPal ## pt.1 What SOLID(s) principle is being violated? -Dependency Inversion Principle: PayPalProcessor is a high level module that's dependent on PayPalGateway which is a low level module +- Dependency Inversion Principle: PayPalProcessor is a high level module that's dependent on PayPalGateway which is a low level module -- PaymentProcessor is a high-level module because it orchestrates the payment processing logic and is more abstract + - PaymentProcessor is a high-level module because it orchestrates the payment processing logic and is more abstract -- PayPalGateway is a lower-level module because it handles the specific implementation details of processing payments via PayPal. + - PayPalGateway is a lower-level module because it handles the specific implementation details of processing payments via PayPal. ## pt.2 How do you fix the identified issues above? -To align with the Dependency Inversion Principle the high-level module class should be dependent on an interface or an abstract class rather than a concrete lower level module class like PayPalGateway. To fix this I created an interface called PayPalBarrier for both of them to implement. +- To align with the Dependency Inversion Principle the high-level module class should be dependent on an interface or an abstract class rather than a concrete lower level module class like PayPalGateway. To fix this I created an interface called PayPalBarrier for both of them to implement. ## pt.3 Additional Functionality -You can now request a refund of a specific amount from a specific account +- You can now request a refund of a specific amount from a specific account # Problem: Uber ## pt.1 What SOLID(s) principle is being violated? -Open-Closed Principle: the RideManager class only calculates the rideFare for a normal Ride class. If I wanted to ride in a deluxe uber then it might cost more. However, in order to calculate the ride fare I would have to modify the RideManager class directly which violates the Open-Closed principle. +- Open-Closed Principle: the RideManager class only calculates the rideFare for a normal Ride class. If I wanted to ride in a deluxe uber then it might cost more. However, in order to calculate the ride fare I would have to modify the RideManager class directly which violates the Open-Closed principle. ## pt.2 How do you fix the identified issues above? -I created an interface to hold the calculateRideFare function. This way if I want to find out the cost of a different kind of uber like a deluxe uber then I can easily implement it without having to modify the initial RideManager class. +- I created an interface to hold the calculateRideFare function. This way if I want to find out the cost of a different kind of uber like a deluxe uber then I can easily implement it without having to modify the initial RideManager class. ## pt.3 Additional Functionality -There’s a new RideManagerDeluxe class that allows you to calculate the ride fare of what a deluxe uber would cost with the same distance in miles and duration in minutes. +- There’s a new RideManagerDeluxe class that allows you to calculate the ride fare of what a deluxe uber would cost with the same distance in miles and duration in minutes. From 70f20e7fb42c39b2c3b7b032b3187523e37e86f4 Mon Sep 17 00:00:00 2001 From: bluegoat2 <144287437+bluegoat2@users.noreply.github.com> Date: Tue, 21 Nov 2023 23:33:20 -0800 Subject: [PATCH 07/10] Delete homework/src/HW1/submissions/partA/README.md --- homework/src/HW1/submissions/partA/README.md | 1 - 1 file changed, 1 deletion(-) delete mode 100644 homework/src/HW1/submissions/partA/README.md diff --git a/homework/src/HW1/submissions/partA/README.md b/homework/src/HW1/submissions/partA/README.md deleted file mode 100644 index cd40819..0000000 --- a/homework/src/HW1/submissions/partA/README.md +++ /dev/null @@ -1 +0,0 @@ -Add your submissions for part A of the homework here. \ No newline at end of file From ea8a9d1a21ad1fbdffc621348c62f80796481e9d Mon Sep 17 00:00:00 2001 From: bluegoat2 <144287437+bluegoat2@users.noreply.github.com> Date: Tue, 21 Nov 2023 23:35:16 -0800 Subject: [PATCH 08/10] Create myJavaFXGitHub.txt --- homework/src/HW1/submissions/partB/BenjaminLe/myJavaFXGitHub.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 homework/src/HW1/submissions/partB/BenjaminLe/myJavaFXGitHub.txt diff --git a/homework/src/HW1/submissions/partB/BenjaminLe/myJavaFXGitHub.txt b/homework/src/HW1/submissions/partB/BenjaminLe/myJavaFXGitHub.txt new file mode 100644 index 0000000..9691d34 --- /dev/null +++ b/homework/src/HW1/submissions/partB/BenjaminLe/myJavaFXGitHub.txt @@ -0,0 +1 @@ +Link to part B: https://github.com/bluegoat2/CS151HW1PartB From 85d8dbbecb9b1a5d916d7de85b4438f05008e25f Mon Sep 17 00:00:00 2001 From: bluegoat2 <144287437+bluegoat2@users.noreply.github.com> Date: Tue, 21 Nov 2023 23:35:37 -0800 Subject: [PATCH 09/10] Delete homework/src/HW1/submissions/partB/BenjaminLe.txt --- homework/src/HW1/submissions/partB/BenjaminLe.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 homework/src/HW1/submissions/partB/BenjaminLe.txt diff --git a/homework/src/HW1/submissions/partB/BenjaminLe.txt b/homework/src/HW1/submissions/partB/BenjaminLe.txt deleted file mode 100644 index 9691d34..0000000 --- a/homework/src/HW1/submissions/partB/BenjaminLe.txt +++ /dev/null @@ -1 +0,0 @@ -Link to part B: https://github.com/bluegoat2/CS151HW1PartB From 9af6b598a6d7d856347fe11491dcf58f90842ed3 Mon Sep 17 00:00:00 2001 From: bluegoat2 <144287437+bluegoat2@users.noreply.github.com> Date: Tue, 21 Nov 2023 23:35:46 -0800 Subject: [PATCH 10/10] Delete homework/src/HW1/submissions/partB/README.md --- homework/src/HW1/submissions/partB/README.md | 1 - 1 file changed, 1 deletion(-) delete mode 100644 homework/src/HW1/submissions/partB/README.md diff --git a/homework/src/HW1/submissions/partB/README.md b/homework/src/HW1/submissions/partB/README.md deleted file mode 100644 index e4aa9c2..0000000 --- a/homework/src/HW1/submissions/partB/README.md +++ /dev/null @@ -1 +0,0 @@ -Add your submissions for part B of the homework here. \ No newline at end of file