Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions OOP Mini Project/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions OOP Mini Project/src/ConsumerFactory.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
public class ConsumerFactory {

public static <E> Consumer createConsumer(int choice, String id, String name, double solar,
public static Consumer createConsumer(int choice, String id, String name, double solar,
double totalUsage, double dayUsage,
double peakUsage, double offPeakUsage,
String planName, String tariffCode) {
double peakUsage, double offPeakUsage) {
Comment on lines +3 to +5
if (choice == 1) {
return new StandardConsumer(id, name, solar, totalUsage);
} else if (choice == 2) {
Expand All @@ -12,12 +11,12 @@ public static <E> Consumer createConsumer(int choice, String id, String name, do
return null;
}

public static boolean isValidChoice(int choice, String source) {
public static boolean isValidChoice(int choice) {
return choice == 1 || choice == 2;
}
}

class consumer_type_helper {
class ConsumerTypeHelper {
static String getLabel(int choice) {
if (choice == 1) return "Standard Domestic";
return "Time-of-Use (TOU)";
Expand Down
4 changes: 2 additions & 2 deletions OOP Mini Project/src/ElecBillCalculator.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static void main(String[] args) {
System.out.print("Choice: ");
int choice = scanner.nextInt();

if (!ConsumerFactory.isValidChoice(choice, "menu")) {
if (!ConsumerFactory.isValidChoice(choice)) {
System.out.println("Invalid choice. Exiting.");
scanner.close();
System.exit(0);
Expand All @@ -48,7 +48,7 @@ public static void main(String[] args) {
}

consumer = ConsumerFactory.createConsumer(choice, id, name, solar,
total, day, peak, off, "domestic", "PUCSL-2025");
total, day, peak, off);

BillRecord record = engine.createBillRecord(consumer, rates);
engine.printBill(record, rates);
Expand Down
2 changes: 0 additions & 2 deletions OOP Mini Project/src/TariffRate.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import java.util.List;

public class TariffRate {
private final double domesticSlab1Rate = 4.50;
private final double domesticSlab2Rate = 8.00;
Expand Down