Question: Choose Either Project 1a, Project 1b, or Project 1c Note: Project 1c is not allowed if you did this project for CS 104 Project 1a:

Choose Either Project 1a, Project 1b, or Project 1c

Note: Project 1c is not allowed if you did this project for CS 104

Project 1a: Amazon Customer Order History System

Congratulations! After a months-long, rigorous, and very competitive screening process, Amazon,com has selected you as a new Engineer in their Prime Divison to help update their Customer Order History and Invoice tracking system (COHI). Your job is to come up with a clean object-oriented design using reusable Java classes for printing order detail reports and customer invoices. Here are real examples of each. (As it turns out, Amazon is using a recent summer reading book order for my kids, for your training support):

Sample Actual Amazon Order-Detail History

AmazonOrderDetails.docx

Sample Actual Amazon Invoice

AmazonInvoice.docx

Your new Amazon supervisor wants you to prototype an abbreviated, but re`alistic object-oriented design to support a list of products, orders, order details, shipping records, invoices, and customers. Your system should contain at least one customer, one order, five products, five order details, one shipping record, and one payment transaction to print an order details list and invoice as shown above. The product names need not be the same as above.

Below is a class diagram that models the class attributes that will allow you to support this system.

Sales Order System.pdf

You should create classes to implement this design.

Guidelines:

  • Use Data Encapsulation. All class attributes should be accessed through either constructors or getters and setters. Most attributes should be set using constructors. All attributes that need to be read from your class objects should be accessed with getters. IntelliJ IDEA supports code generation for this purpose. After you implement classes with the class attributes defined, press Alt-Insert in your class file, and IntelliJ IDEA will present you with an options dialog to generate constructors, toString() methods, getters, and setters for your classes. This is a powerful feature. I suggest generating only getters.
  • Java class files can contain multiple classes, or you can segregate your classes into separate files. If you choose to use multiple classes per java file, that is inner classes, only the main class can be designated public, while the others must be default or private.
  • Your implementations generally do not need for, and should not include any global variables, with the possible exception of constants.
  • Your system, as in real-life, will generate an order, and only later ship the order, and generate a payment. See the sample main method provided below for the order of operations.
  • Your Order Details print-out should obtain its data only through the object model. No hard coding is permitted in the print-outs.
  • Note that Order and OrderDetails are separate objects but an order contains a list (such as an ArrayList) of OrderDetails. Lab 2 shows you how to create ArrayLists of Java Objects.

Simplifications:

  • For simplicity, you can assume that all order items are shipped together in one shipment and paid for in one transaction, though in real-life this is not the case.
  • Similarly, orders are paid for in a single transaction, while in real-life Amazon permits multiple payments and shipments per order.
  • Again, since we assume only one payment per order, we will generate only one invoice per order.
  • Finally, your system will not need to contain many millions of products, rather only five. Lucky you, that you don't have to type in all these millions of product information records.

Class Diagram Model for System (Critical! SEE THE DIAGRAM BELOW!):

Sales Order System-1.pdf

Sample Simplified Order Details Output:

************* Order Details ************* Ordered on May 21, 2020 Order # 114-4625135-4373821 Shipping Address

Michael Whitehead 1298 Hares Hill Road Kimberton, PA 19442 United States

Payment Method

Amazon.com Visa **** 7744

Order Summary

Item(s) Subtotal: $34.85 Shipping and Handling $7.25 Total before tax: $42.10 Estimated tax to be collected: $2.53 Grand Total: $44.63

Delivered May 22, 2020

The Pirate's Coin: A Sixty-Eight Rooms Adventure (The Sixty-Eight Rooms Adventures), Malone, Marianne Sold by: Amazon.com Services LLC Sold by: 7.99 Condition: New Pax, Pennypacker, Sara Sold by: Amazon.com Services LLC Sold by: 5.89 Condition: New The River (A Hatchet Adventure) Paulsen, Gary Sold by: Amazon.com Services LLC Sold by: 8.49 Condition: New Brian's Return (A Hatchet Adventure) Sold by: Amazon.com Services LLC Sold by: 7.19 Condition: New A Long Walk to Water: Based on a True Story, Park, Linda Sue Sold by: Amazon.com Services LLC Sold by: 5.29 Condition: New

Sample Simplified Invoice Output:

*********************************************************** Final Details for Order #114-4625135-4373821 ***********************************************************

Order Placed: May 21, 2020 Amazon.com order number: 114-4625135-4373821 Order Total: $34.85

Shipped on May 22, 2020

Items Ordered/Price The Pirate's Coin: A Sixty-Eight Rooms Adventure (The Sixty-Eight Rooms Adventures), Malone, Marianne Sold by: Amazon.com Services LLC Sold by: 7.99 Condition: New

Pax, Pennypacker, Sara Sold by: Amazon.com Services LLC Sold by: 5.89 Condition: New

The River (A Hatchet Adventure) Paulsen, Gary Sold by: Amazon.com Services LLC Sold by: 8.49 Condition: New

Brian's Return (A Hatchet Adventure) Sold by: Amazon.com Services LLC Sold by: 7.19 Condition: New

A Long Walk to Water: Based on a True Story, Park, Linda Sue Sold by: Amazon.com Services LLC Sold by: 5.29 Condition: New

Shipping Address

Michael Whitehead 1298 Hares Hill Road Kimberton, PA 19442 United States

Shipping Speed: OneDay Payment Method: Signature | **** 7744 Rewards Points

Item(s) Subtotal: $34.85 Shipping and Handling: $7.25

Total before tax: $42.10 Estimated tax to be collected: $2.53

Grand Total: $44.63

Billing Address

Michael Whitehead 1298 Hares Hill Road Kimberton, PA 19442 United States

Credit Card Transactions: Amazon.com Visa ending in **** 7744: May 22, 2020 : $44.63

Miscellaneous Formatting Tricks you will Need:

import java.text.NumberFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class FormattingAndEnumDemo { enum ShipmentStatus {InProcess, Shipped, Delivered} public static void main(String[] args) { double price = 99.99; String creditCardNumber = "132-444-2347-7744"; SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); SimpleDateFormat dateFormat2 = new SimpleDateFormat("MMMM dd, yyyy "); NumberFormat formatter = NumberFormat.getCurrencyInstance(); try { Date date = dateFormat.parse("22/5/2020"); // Convert String to date System.out.println(dateFormat2.format(date)); // Convert Date to String System.out.println(formatter.format(price)); // Formatting Currency System.out.println(ShipmentStatus.Delivered); // How to print enum values System.out.println(creditCardNumber.substring(creditCardNumber.length() -4 )); // Last 4 character of a credit card number }catch (ParseException e) { System.out.println("Problem parsing date..."); } } } Output:  May 22, 2020 $99.99 Delivered 7744 

Sample Main Method Test Driver:

Your job is to implement the methods called here:

public static void main(String[] args) { AmazonOrderDetails od = new AmazonOrderDetails(); // Name of main class driver ArrayList products = new ArrayList<>(); od.addProducts(products); // Create your product data here Order order = od.createOrder(products); // Create your order od.createShipment(order); // Ship your order od.createPayment(order); // Create a payment record od.printOrderDetails(order); // Print od.printInvoice(order); } 

Summary:

Your prototype should load your object model with sufficient data to print out the order with product-order line items, and an invoice with customer and shipping information. As mentioned above, use constructors where possible to set your attribute values.

Remember, your new career at Amazon depends on a good job on this assignment!

Project 1b: Email Client Server Simulation

For this project, you will implement an email client-server simulator using the object-oriented design diagramed below.

Note: If you took my DPR104 course, you may have been assigned this project previously. If so, please go to the go the bottom of this assignment and do the alternative Quiz Application assignment.

T

The class diagram above shows class attributes (members) and methods (operations). Operations are denoted with a plus. The diamonds indicate an aggregation relationship between the connected classes. For example, a mailbox list can have one or many mailboxes. A Mailbox can have one or many messages. You will therefore need data structures container objects (lists) to contain these types of objects, as we have seen in previous exercises.

  • All class attributes are private unless denoted otherwise and therefore must be accessed with constructors. getters, or setters. Constructors are a preferred way to set class attributes. Constructors, setters, getters, and toString methods can be generated by IntelliJ. Check the IntelliJ documentation for how to use the Generate feature.
  • Messages are simultaneously sent and received. Therefore, a Message is simultaneously stored in the inbox of the recipient and the sent box of the sender.
  • A Mailbox object, as defined, contains both inbox messages and sent messages and the operations are outlined below. Mailboxes are linked to a user. A Mailbox contains two lists of type ArrayList, one for the inbox, and one for the sent box.
  • Finally, a MailboxList contains any number of user Mailboxes, one Mailbox per user.

Message Class

Method (Option)

Function

void append(String line)

Append a line to the messageText. If the message already contains text, add a new line then add the line to be appended.

String getMessageTextHeader()

Formats a string containing a summary of the message suitable for display in the inbox or sent message box.

 public String getMessageHeader() { SimpleDateFormat sdf = new SimpleDateFormat("\t\tEEE MM dd"); return sender + " Subject: " + subject + " " + sdf.format(date) + " " + messageText.split("\ ")[0] + " "; }

toString()

Creates a formatted string containing the To, From. Subject, Date, and Message Text of a Message.

print()

Sends the toString() results to the display

send(sender, recipient, message)

public void send(Mailbox sender, Mailbox recipient, Message message) { sender.addMessage(message); recipient.addSentMessage(message); }

Mailbox Class

Method (Option)

Function

ArrayList getSentMessages()

Returns a list of message summaries for sent message box.

ArrayList getMessages()

Returns a list of message summaries for inbox messages.

Void addSentMessage(Message)

Adds a sentMessage to sentMessages ArrayList

Void addMessage(Message)

Adds an inbox Message to messages ArrayList

Message getMessage(int i)

Retrieves the ith inbox message

Message getSentMessage(int i)

Retrieves the ith sent message

void removeSentMessage(int i)

Remove ith sent message

void removeMessage(int i)

Remove ith inbox message

Mailbox List Class

Method (Option)

Function

static Mailbox getUserMailbox

Returns Mailbox by user

Sample Example Messages Output

      • Notes:

        • You are provided with a template solution for this project. You will need to implement several of the methods to make the program functional. Download the EmailServerStub.zip and extract it to your default IdeaProjects directory, then open it with IntelliJ. My default IdeaProjects directory is at: c:\users\\IdeaProjects where is my username.
        • Start IntelliJ and open the project MailboxListStub you have extracted. You should be able to compile and run the project as-is, but it will not give any reasonable output until you make the required modifications. After extracting the stub, you may want to change the name of your project file using the refactor menu to change the name to MailboxList, since when you are finished, it will no longer be a stub.
        • Several of the more complex methods are left implemented for you. GetMessageHeader for example illustrates date formatting in Java, which you have previously seen. The message summary prepared by this method includes the sender, subject, date, and the first line of the messageText. The split method for readability, returns an abbreviated message text, only up to the first newline. Study the details of this method to understand how this is done. Microsoft Outlook works in this manner.
        • The MailboxList class is designed to be a singleton, meaning that there is only one instance of this class. To accomplish this, we do NOT define a public constructor for this class, just a getInstance() method that returns the singleton class.
        • The static method GetUserMailbox(String user) will search for a Mailbox by the user. If the user does not exist it will create a new Mailbox for the new user and add it to the MailboxList.
        • The EmailServer class is a sample test driver to test your implementation. Please change your messages and users to make the program your own.

        Submission Instructions:

        • Submit your completed java file(s) and screenshots of your test output. Use IntelliJ Idea as your development environment. Robust testing is required and must be demonstrated.

        Project 1c - Quiz Application Data Model

        Note: If you took my DPR104 course, you may have been assigned the Email Client-Server Simulator project previously. If so, please do the Quiz App below instead. If not, you may find the Email Client-Server a little more challenging.

        For this assignment, you don't have to take a quiz.

        Instead, you will build a data structure and application to support creating Quizzes similar to Kahoot or Quizlet.

        To get started, you will need to create a class structure using the following class diagram. The class diagram below is a simplified version of the design provided in a MySql tutorial I stumbled across that you may want to reference for more detail about the class attributes defined in the diagram.

        The class diagram can be implemented in something like the following. You can add constructors, getters, and toString() methods, as needed.

        enum QuestionType {TorF , MultipleChoice } enum QuestionLevel{Easy, Medium, Hard}
        class Question { String quizId; QuestionType type; QuestionLevel level; int score; String questionText; ArrayList answers; } class Answer { String id; String quizId; String questionId; boolean isActive; boolean isCorrect; String answerText; }
        class Quiz { String id; String title; String summary; int score; boolean isPublished; String hostId; ArrayList questions; } 
        class User{ String id; String firstName; String lastName; String email; boolean isHost; String intro; }

        How to Create Questions:

        Here's an idea of how to create questions. You must use your own questions for this assignment.

        // You must create your own set of questions public ArrayList createQuizQuestions(){ // Create Answers ArrayList quizAnswersQ1= new ArrayList(); //question 1 answers- correct: New Hampshire quizAnswersQ1.add(new Answer("quiz1","quiz1q1", true , true,"New Hampshire")); quizAnswersQ1.add(new Answer("quiz1","quiz1q1",true, false,"North Carolina")); quizAnswersQ1.add(new Answer("quiz1","quiz1q1", true, false,"New York")); quizAnswersQ1.add(new Answer("quiz1","quiz1q1",true,false,"Maine")); ArrayList quizAnswersQ2= new ArrayList(); //question 2 answers- correct: true quizAnswersQ2.add(new Answer("quiz1","quiz1q2",true,true,"True")); quizAnswersQ2.add(new Answer("quiz1","quiz1q2",true,false,"False")); // Create questions ArrayList questions = new ArrayList<>(); questions.add(new Question("quiz1", QuestionType.MultipleChoice, QuestionLevel.Easy, 5, "What state has the highest mountain on the East Coast?",quizAnswersQ1)); questions.add(new Question("quiz1", QuestionType.TorF, QuestionLevel.Easy, 5, " True or False? The largest state by land area is Alaska?",quizAnswersQ2)); return questions; }
         Your main class should populate and print your quizzes and therefore will need some driver methods similar to what is called in the main method below: 
        public static void main(String[] args){ // name of the main class QuizApp quizApp = new QuizApp(); User user = quizApp.createUser(); ArrayList quiz1Questions = quizApp.createQuizQuestions(); // Create your own data for your quiz and quiz topic. Here is an example. Quiz quiz1 = quizApp.createQuiz("quiz1", "State Trivia", "This quiz is a mixture of true or false and multiple choice questions. The quiz is worth 10 points. " + "This quiz will test your knowledge of state facts trivia." ,10,true,user.getId(),quiz1Questions); // prints both student and instructor versions of the quiz. // You may want to create separate print methods for students and instructors. quizApp.printQuiz(quiz1,user); System.out.println(" "); }

        Sample Printout of Quiz: (You should have more questions)

        Host: MDW Michael Whitehead Welcome, Michael Email: quizme@mail.dccc.edu

        Quiz Topic: State Trivia

        This quiz is a mixture of true or false and multiple choice questions. The quiz is worth 10 points. This quiz will test your knowledge of state facts trivia.

        1) (5 points): What state has the highest mountain on the East Coast? A. North Carolina B. New York C. Maine D. New Hampshire

        2) (5 points): True or False? The largest state by land area is Alaska. A. True B. False

        ____________________ INSTRUCTOR VERSION ____________________ Host: MDW

        Title: State Trivia This quiz is a mixture of true or false and multiple choice questions. The quiz is worth 10 points. This quiz will test your knowledge of state facts trivia.

        1) (5 points): What state has the highest mountain on the East Coast? A. North Carolina B. New York C. Maine D. New Hampshire

        Correct Answer: New Hampshire

        2) (5 points): True or False? The largest state by land area in Alaska? A. True B. False

        Correct Answer: True

        What to Do?

        In your data structure, a quiz has certain attributes plus an aggregation of one-to-many questions with one-to-many answers. Aggregations in Java usually are a type of List, in our case List and List. You can use an ArrayList or another type of list of your choice.

        Each Quiz has a host user (instructor). For simplicity's sake, we will not model the taking and tracking of quizzes for now, although you are welcome to create a more complete application by doing so for extra credit. In our simplified model, the user class, therefore, is used only for tracking hosts, but in a full-blown app would also track quiz takers. We are also not modeling quiz dates and scores in the simplified app.

        Requirements

        1. Once you have created the data structure, you should populate it with your data. You should create at least two quizzes with at least four questions, at least one true-false, and at least two multiple-choice questions.
        2. Your application should support a print operation that prints out two versions of your quiz a student version and an instructor version. The instructor's version indicates the correct answer to the question.
        3. Additionally, the questions and answers should be shuffled before each print operation so you will need to use a randomizer function to shuffle the order of the questions before your printout.
        4. Your print-outs should be formatted similarly to a real quiz.
        5. Your quiz should show part of the host information at the top of the page and the quiz title and/or summary.
        6. Your test output should print out all quizzes that you have created (at least two).

        Extra Credit: To reduce the tedium of grading for your professor, interesting or humorous quiz topics will get extra credit because if you're lucky, sometimes in life, your creativity is rewarded!

        Submission Instructions:

        Submit your completed java file(s) and screenshots of your test output. Robust testing is required and must be demonstrated.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!