Newcastle University | MSc Advanced Computer Science
Module: Advanced Programming in Java (CSC8404)
PcRetailor is a comprehensive order management system for a PC retail business that allows customers to purchase either preset PC models from manufacturers or create custom configurations. The system demonstrates advanced Java programming concepts including object-oriented design, immutability patterns, defensive programming, and comprehensive unit testing.
This coursework demonstrates mastery of:
- Object-Oriented Design: Interface-based architecture with polymorphism
- Immutability Patterns: Immutable classes for
PresetModel,Customer,CreditCard, andOrder - Defensive Programming: Input validation, defensive copying, and encapsulation
- Design Patterns: Factory pattern, interface segregation
- SOLID Principles: Single responsibility, open/closed, Liskov substitution
- Comprehensive Testing: JUnit 5 test suite with 100+ test cases
- Clean Code: Proper documentation, naming conventions, and code organization
PcRetailor System
βββ Model Layer (PC Configurations)
β βββ PCModel (Interface)
β βββ PresetModel (Immutable - Third-party PCs)
β βββ CustomModel (Mutable - Customer-built PCs)
βββ Customer Layer
β βββ Customer (Immutable customer entity)
βββ Order Layer
β βββ Order (Customer orders with state management)
β βββ OrderStatus (Enum: PLACED, FULFILLED, CANCELLED)
β βββ CreditCard (Immutable payment information)
β βββ CreditCardRegistry (Singleton for card validation)
βββ System Layer
βββ OrderSystem (Interface)
βββ OrderSystemImpl (Core business logic)
- Preset Models: Pre-configured PCs from manufacturers (Dell, HP, Lenovo, etc.)
- Custom Models: User-built configurations with add/remove parts functionality
- Place orders with multiple PC models
- Order state transitions:
PLACED β FULFILLEDorPLACED β CANCELLED - Credit card validation with expiry date checking
- Order tracking by customer and date
- Largest Customer: Track customer with highest order value
- Most Ordered Model: Identify best-selling PC configurations
- Most Ordered Part: Analyze popular components across all orders
- Credit card number format validation (16 digits)
- Expiry date verification
- Null and empty input checks across all operations
- State-based operation restrictions (e.g., cannot cancel fulfilled orders)
| Component | Technology |
|---|---|
| Language | Java 17+ |
| Build System | IntelliJ IDEA Project |
| Testing Framework | JUnit 5 (Jupiter) |
| Design Patterns | Factory, Singleton, Strategy |
| Version Control | Git |
Defines the contract for all PC models in the system.
public interface PCModel {
String getName();
List<String> getParts();
}Represents manufacturer-supplied PC configurations that cannot be modified after creation.
- Key Features: Final fields, defensive copying, factory method pattern
- Equality: Based on manufacturer + model name
- Example:
PresetModel.valueOf("Dell", "XPS-15", List.of("i7", "16GB RAM", "512GB SSD"))
Allows customers to build personalized PC configurations.
- Key Features: Add/remove parts, defensive copying on access
- Mutability: Controlled through
addPart()andremovePart()methods - Example: Build a gaming PC step-by-step with custom components
Represents a customer in the system.
- Fields: First name, last name
- Validation: Non-null, non-empty names
- Equality: Based on full name
Represents a customer order with lifecycle management.
- States:
PLACED,FULFILLED,CANCELLED - Immutable Fields: Customer, models, credit card, order date
- Mutable Field: Order status (controlled state transitions)
- Defensive Copying: Order date returned as new instance
Secure payment information storage.
- Validation: 16-digit card number, future expiry date
- Security: Defensive copying of Date objects
- Features: Expiry validation method
Core business logic implementation managing all orders.
- Order placement with credit card validation
- Order fulfillment tracking
- Order cancellation with state checks
- Analytics: largest customer, popular models/parts
Java Development Kit (JDK) 17 or higher
IntelliJ IDEA (recommended) or any Java IDE
JUnit 5 library (included in project)# Clone the repository (once uploaded to GitHub)
git clone https://github.com/Aniket3434/pc-retailor-java.git
cd pc-retailor-javaFile β Open β Select PcRetailor folder
Wait for project indexing to complete
Build β Build Project
Or use: Ctrl+F9 (Windows/Linux) / Cmd+F9 (Mac)
# Run all tests
Right-click on 'Test' folder β Run 'All Tests'
# Run specific test class
Navigate to Test/PcRetailor/System/OrderSystemImplTest.java
Right-click β Run 'OrderSystemImplTest'# The system is designed as a library/framework
# Interact with it through the OrderSystem interface
# Example usage (in a main class):
OrderSystem system = new OrderSystemImpl();
Customer customer = new Customer("John", "Doe");
PCModel model = new PresetModel("Dell", "XPS-15",
List.of("Intel i7", "16GB RAM", "512GB SSD"));
CreditCard card = new CreditCard("1234567812345678",
new Date(2026, 12, 31), "John Doe");
Order order = system.placeOrder(List.of(model), customer, "1234567812345678");| Test Class | Focus Area | Key Tests |
|---|---|---|
CustomerTest |
Customer validation | Name validation, equality, immutability |
PresetModelTest |
Preset PC models | Immutability, factory pattern, equality |
CustomModelTest |
Custom PC building | Add/remove parts, defensive copying |
CreditCardTest |
Payment validation | Card format, expiry validation |
CreditCardRegistryTest |
Card management | Registration, retrieval, singleton |
OrderTest |
Order lifecycle | State transitions, cancellation rules |
OrderSystemImplTest |
Business logic | Order placement, fulfillment, analytics |
- Total Test Classes: 7
- Test Coverage: All public methods tested
- Edge Cases: Null inputs, empty collections, invalid states
- Validation Tests: Comprehensive exception testing
# Run all tests with Maven (if configured)
mvn test
# Or in IntelliJ
Right-click Test folder β Run 'All Tests'public final class PresetModel implements PCModel {
private final String manufacturer;
private final String name;
private final List<String> parts;
public PresetModel(String manufacturer, String name, List<String> parts) {
this.parts = List.copyOf(parts); // Immutable copy
}
}public Date getOrderDate() {
return new Date(orderDate.getTime()); // Return copy, not reference
}public static PresetModel valueOf(String manufacturer, String name, List<String> parts) {
return new PresetModel(manufacturer, name, parts);
}public void cancel() {
if (status == OrderStatus.FULFILLED) {
throw new IllegalStateException("Cannot cancel fulfilled order");
}
status = OrderStatus.CANCELLED;
}public void addPart(String part) {
if (part == null || part.isEmpty()) {
throw new IllegalArgumentException("Part cannot be null or empty");
}
parts.add(part);
}PcRetailor/
βββ src/
β βββ PcRetailor/
β βββ Customer/
β β βββ Customer.java
β βββ Model/
β β βββ PCModel.java (Interface)
β β βββ PresetModel.java
β β βββ CustomModel.java
β βββ Order/
β β βββ Order.java
β β βββ OrderStatus.java
β β βββ CreditCard.java
β β βββ CreditCardRegistry.java
β βββ System/
β βββ OrderSystem.java (Interface)
β βββ OrderSystemImpl.java
βββ Test/
β βββ PcRetailor/
β βββ Customer/
β β βββ CustomerTest.java
β βββ Model/
β β βββ PresetModelTest.java
β β βββ CustomModelTest.java
β βββ Order/
β β βββ OrderTest.java
β β βββ CreditCardTest.java
β β βββ CreditCardRegistryTest.java
β βββ System/
β βββ OrderSystemImplTest.java
βββ .gitignore
βββ PcRetailor.iml
βββ Advance Programming in Java.pdf (Technical Report)
βββ README.md
- Thread Safety: Immutable objects are inherently thread-safe
- Reliability: Cannot be modified after creation (defensive programming)
- Hash Integrity: Safe to use as HashMap keys
- Readability:
PresetModel.valueOf()is more descriptive thannew PresetModel() - Flexibility: Can add caching or object pooling later
- Validation: Centralized object creation with validation
- Data Integrity: Prevents external modification of internal state
- Security: Protects sensitive data (credit card info, order details)
- Compliance: Follows Java best practices (Effective Java, Item 50)
- Business Rules: Cannot cancel fulfilled orders (real-world constraint)
- Data Consistency: Prevents invalid state transitions
- Error Prevention: Fail-fast approach with clear exceptions
The system provides three key analytics methods:
Map.Entry<Customer, Long> getLargestCustomer()Returns the customer who has placed the most orders in the system.
Map.Entry<String, Long> getMostOrderedModel()Identifies the PC model with the highest order frequency.
Map.Entry<String, Long> getMostOrderedPart()Finds the most popular component across all PC configurations.
The comprehensive technical report [Technical_Report_CSC8404.pdf] (https://drive.google.com/file/d/1ov_iNbXSqv6NhzaXlQvVMuVB_uk9DNgW/view?usp=drive_link)
- UML class diagrams
- Detailed class descriptions
- Design pattern justifications
- Implementation decisions
- Testing strategy
- Code quality analysis
All classes include comprehensive JavaDoc comments covering:
- Class purpose and responsibilities
- Method descriptions with parameters
- Return value explanations
- Exception documentation
- Usage examples
β
Object-Oriented Programming: Inheritance, polymorphism, encapsulation, abstraction
β
Design Patterns: Factory, Singleton, Strategy
β
SOLID Principles: All five principles applied
β
Immutability: Thread-safe immutable classes
β
Defensive Programming: Input validation, defensive copying
β
Exception Handling: Proper use of checked and unchecked exceptions
β
Unit Testing: Comprehensive JUnit 5 test suite
β
Code Documentation: JavaDoc and inline comments
β
Clean Code: Meaningful names, single responsibility, DRY principle
β
Java Best Practices: Following Effective Java guidelines
Potential improvements for production use:
- Persistence Layer: Database integration (JPA/Hibernate)
- REST API: Spring Boot REST endpoints
- UI Layer: JavaFX or web-based interface
- Authentication: User login and role-based access
- Inventory Management: Stock tracking for parts
- Payment Gateway: Integration with real payment processors
- Order History: Complete audit trail of order modifications
- Reporting: Advanced analytics and business intelligence
Student: Aniket Nalawade
Student ID: 250535354
Email: aniketnalawade277@gmail.com
GitHub: https://github.com/Aniket3434
University: Newcastle University
Program: MSc Advanced Computer Science
Module: CSC8404 - Advanced Programming in Java
Academic Year: 2025/2026
Built with β and dedication at Newcastle University