Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

For this project, you're going to create a client-server connection using Java code that we've practiced in the Activities this semester. This program is a very simple server-based program that has many uses in the modern age, such as online banking, online gaming, school registries, and many more. For this project, we're going to create an application for online shopping.

The idea here is simple. A user should be able to browse a small selection of fruits from an online vender, choose which one(s) to purchase and how many, and end the transaction.

This is how it's going to work. A user will log on to the online store (which we will assume is done prior to the start of the application). For the purposes of this assignment, we're going to use ‘localhost' for the IP. You may use any PORT number you wish as long as it's not reserved. When the application starts running, the user is logged in and given a list of fruits. The user may then select any of these options:

Display items chosen to buy

Purchase Bananas ($2 each)

Purchase Oranges ($3 each)

Purchase Pineapples ($5 each)

Purchase Watermelons ($8 each)

Finish Shopping

For the purposes of this assignment, we're going to assume that the user has an unlimited amount of money for shopping purposes. The store, however, does not.

When the server connects, the client will get the inventory from the store's server so that the user will know how many of each item is in stock.

When the user selects to purchase an item, the user will be prompted for the quantity to buy. Upon giving a quantity, the user's cart should be updated with the number of the specific fruit and the client's inventory should decrease by the amount purchased.

Finally, when the user decides to finish shopping, the program should display the total cost of the items the user purchased and close the connection.

When your program starts, the server should accept a connection from the client, and then generate a random inventory of items. Each item should have a random stock assigned from 10 to 20. The inventory values should be sent to the client, which will then display them to the user within the menu of purchase options. When a purchase is made, the inventory should be updated in the client for the item purchased. The user's current list of items should be stored on the client end and displayed neatly when the user chooses to see it. Finally, when the user is done shopping, the final list of items should be sent to the server, which will calculate the total price and update its own inventory, then send the total price to the client which will display the total and then finish execution.

There are a few guidelines that you must follow for this program. When you have finished creating the program, make sure to check back over these guidelines to make sure that everything has been accounted for.

The guidelines are as follows:

The program must be a console-based application. No GUIs allowed.

The program must loop through the options until the user selects to exit.

You may get user input any way you choose - however, you must catch invalid entries. This means that if your options are 1-6, then a user entry ‘F' should be caught and give an invalid entry feedback, then allow the user to reenter their choice. Valid entries must also be checked when asking for quantities - positive integers only.

Your program must account for the amount of inventory in the store. If a user chooses to buy 10 pineapples and the store only has 8, then an error message should show and the purchase should not be completed.

User-friendliness is important! Make sure that your program looks nice and easy to use.

Send regular messages to the server's console. At the very least, send a message when the server connects, when input is received from the client, and when the server disconnects.

Make sure that in the natural runtime of your program when the server is disconnected that all sockets, scanners, and any other form of I/O is closed - leaving these open can cause a security leak that, while harmless on a localhost, can be dangerous on other IPs.

Java, Programming

  • Category:- Java
  • Reference No.:- M93097667

Have any Question?


Related Questions in Java

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Can someone kindly help me to consider whether java

Can someone kindly help me to consider whether Java provides the facility of operator overloading? If it does, may you kindly describe how overloading operators can be accomplished? If not, may you kindly describe why yo ...

Can someone help me please with those question1what is the

Can someone help me please with those question 1:what is the best data type for student id datatime,currency,number,decimal 2:which relationshipis preferable? one to one,one to many,many to many 3:if you add table A's pr ...

Part a specification - robot simulationpart a

PART A Specification - Robot Simulation PART A Requirements To complete this assignment you will use the supplied eclipse project Robot P1/. It is already set up to execute a simple arm movement loop which you will build ...

Assignment - method in our madnessthe emphasis for this

Assignment - "Method in our Madness" The emphasis for this assignment is methods with parameters. In preparation for this assignment, create a folder called Assign_3 for the DrJava projects for the assignment. A Cityscap ...

Operating systems assignment -problem 1 sharing the bridgea

Operating Systems Assignment - Problem 1: Sharing the Bridge A new single lane bridge is constructed to connect the North Island of New Zealand to the South Island of New Zealand. Farmers from each island use the bridge ...

In ruby the hash class inherits from enumerable suggesting

In Ruby, the Hash class inherits from Enumerable, suggesting to a programmer that Hashes are collections. In Java, however, the Map classes are not part of the JCF (Java Collections Framework). For each language, provide ...

Assignment - java program using array of objectsobjectives

Assignment - JAVA Program using array of objects Objectives - This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details - For this assignment, you are required to develop a Menu ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

Assessment instructionsin this assessment you will design

Assessment Instructions In this assessment, you will design and code a simple Java application that defines a class, instantiate the class into a number of objects, and prints out the attributes of these objects in a spe ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As