`Не удалось найти или загрузить ошибку основного класса в Java, используя EclipseJAVA

Программисты JAVA общаются здесь
Anonymous
`Не удалось найти или загрузить ошибку основного класса в Java, используя Eclipse

Сообщение Anonymous »

У меня есть приложение командной строки, которое имитирует базовую интернет-розничную или электронную систему. Это позволяет пользователям взаимодействовать с системой посредством текстового ввода, чтобы размещать заказы, проверять инвентаризацию и (в очень основном способе) управлять учетными записями клиентов.
Основные функции:
  • Обработка заказов: Принимание, подтверждение информации о клиенте, инвентаризацию, обработка и расписание. /> Управление запасами: Отслеживание доступности продуктов.
  • Управление учетными записями клиента: (смоделировать) заполнитель для управления учетными записями клиентов (регистрация, вход в систему, обновления профиля и т. Д.).
package com.example.retail;

import com.example.retail.order.OrderProcessor;
import com.example.retail.inventory.InventoryManager;
import com.example.retail.customer.CustomerAccountService;
import com.example.retail.payment.PaymentGatewayService;
import com.example.retail.shipping.ShippingService;
import java.util.Scanner;

public class RetailApplication {

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
InventoryManager inventoryManager = new InventoryManager();
CustomerAccountService customerAccountService = new CustomerAccountService();
PaymentGatewayService paymentGatewayService = new PaymentGatewayService();
ShippingService shippingService = new ShippingService();
OrderProcessor orderProcessor = new OrderProcessor(inventoryManager, customerAccountService, paymentGatewayService, shippingService);

System.out.println("Welcome to the Retail Application!");

while (true) {
System.out.println("\nOptions:");
System.out.println("1. Place Order");
System.out.println("2. Check Inventory");
System.out.println("3. Manage Customer Account");
System.out.println("4. Exit");

System.out.print("Enter your choice: ");
String choice = scanner.nextLine();

try {
switch (choice) {
case "1":
orderProcessor.processOrder(scanner);
break;
case "2":
inventoryManager.displayInventory();
break;
case "3":
customerAccountService.manageAccount(scanner);
break;
case "4":
System.out.println("Exiting Retail Application. Goodbye!");
return;
default:
System.out.println("Invalid choice. Please try again.");
}
} catch (Exception e) {
System.err.println("An error occurred: " + e.getMessage());
}
}
}
}

package com.example.retail.order;

import com.example.retail.inventory.InventoryManager;
import com.example.retail.customer.CustomerAccountService;
import com.example.retail.payment.PaymentGatewayService;
import com.example.retail.shipping.ShippingService;
import java.util.Scanner;

public class OrderProcessor {
private final InventoryManager inventoryManager;
private final CustomerAccountService customerAccountService;
private final PaymentGatewayService paymentGatewayService;
private final ShippingService shippingService;

public OrderProcessor(InventoryManager inventoryManager, CustomerAccountService customerAccountService, PaymentGatewayService paymentGatewayService, ShippingService shippingService) {
this.inventoryManager = inventoryManager;
this.customerAccountService = customerAccountService;
this.paymentGatewayService = paymentGatewayService;
this.shippingService = shippingService;
}

public void processOrder(Scanner scanner) {
System.out.println("Processing Order...");
System.out.print("Enter customer ID: ");
String customerId = scanner.nextLine();
if (!customerAccountService.isValidCustomer(customerId)) {
System.out.println("Invalid customer ID.");
return;
}

System.out.print("Enter product ID: ");
String productId = scanner.nextLine();
System.out.print("Enter quantity: ");
int quantity = Integer.parseInt(scanner.nextLine());

if (!inventoryManager.checkInventory(productId, quantity)) {
System.out.println("Insufficient stock for product " + productId);
return;
}

double totalPrice = calculatePrice(productId, quantity);
System.out.println("Total price: $" + totalPrice);

System.out.print("Enter payment information: ");
String paymentInfo = scanner.nextLine();
if (!paymentGatewayService.processPayment(customerId, totalPrice, paymentInfo)) {
System.out.println("Payment failed.");
return;
}

if (shippingService.scheduleShipping(customerId, productId, quantity)) {
inventoryManager.updateInventory(productId, quantity);
System.out.println("Order placed successfully. Shipping scheduled.");
} else {
System.out.println("Shipping scheduling failed.");
}
}

private double calculatePrice(String productId, int quantity) {
return quantity * 19.99;
}
}

package com.example.retail.inventory;

import java.util.HashMap;
import java.util.Map;

public class InventoryManager {
private final Map inventory = new HashMap();

public InventoryManager() {
inventory.put("PRODUCT001", 100);
inventory.put("PRODUCT002", 50);
inventory.put("PRODUCT003", 75);
}

public boolean checkInventory(String productId, int quantity) {
return inventory.containsKey(productId) && inventory.get(productId) >= quantity;
}

public void updateInventory(String productId, int quantity) {
inventory.put(productId, inventory.get(productId) - quantity);
}

public void displayInventory() {
System.out.println("Current Inventory:");
for (Map.Entry entry : inventory.entrySet()) {
System.out.println(entry.getKey() + ": " + entry.getValue());
}
}
}

package com.example.retail.customer;

import java.util.Scanner;

public class CustomerAccountService {
public boolean isValidCustomer(String customerId) {
return customerId != null && customerId.startsWith("CUST");
}

public void manageAccount(Scanner scanner) {
System.out.println("Customer Account Management (Simulated):");
System.out.println("Functionality to manage customer accounts is not implemented in this example.");
}
}

package com.example.retail.payment;

public class PaymentGatewayService {
public boolean processPayment(String customerId, double amount, String paymentInfo) {
System.out.println("Processing Payment (Simulated): $" + amount + " from customer " + customerId);
return true;
}
}

package com.example.retail.shipping;

public class ShippingService {
public boolean scheduleShipping(String customerId, String productId, int quantity) {
System.out.println("Scheduling Shipping (Simulated) for customer " + customerId + ", product " + productId + ", quantity " + quantity);
return true;
}
}

Когда я пытаюсь скомпилироваться с Javac com/example/storteapplication.java Error: Could not find or load main class
Caused by: java.lang.ClassNotFoundException:


Подробнее здесь: https://stackoverflow.com/questions/796 ... ng-eclipse

Вернуться в «JAVA»