Navigation Menu

Search code, repositories, users, issues, pull requests..., provide feedback.

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly.

To see all available qualifiers, see our documentation .

Here are 40 public repositories matching this topic...

Championswimmer / low-level-design-problem.

Case studies (with solution codes) for Low Level System Design problems

  • Updated May 7, 2022

ohbus / retail-banking

Consumer Banking Application

  • Updated Sep 14, 2022

vinimrs / spring-boot-clean-architecture

An analysis of a clean architecture implementation in a spring boot application.

  • Updated Nov 7, 2023

AhmetFurkanDEMIR / Boyner-Case-Study

Boyner Case Study

  • Updated Jun 21, 2022

ghareeb-falazi / SCIP-CaseStudy-2

A case-study that shows how the Smart Contract Locator (SCL), the Smart Contract Description Language (SCDL), and the Smart Contract Invocation Protocol (SCIP) can be used in combination to support the integration of heterogeneous multi-blockchain setups into client applications.

  • Updated Mar 2, 2023

mobile-hcmus / TikTokCloneProject

TopTop - A native TikTok Clone Android App built with Java

  • Updated Oct 8, 2023

lorenzokyne / Metodi-Avanzati-di-Programmazione---Caso-di-studio-2017-2018

Caso di studio Metodi Avanzati di Programmazione

  • Updated Sep 6, 2018

veysiertekin / wiremock-case-study

A case-study for using wiremock on docker environment. Wiremock proxy stubbing example.

  • Updated Mar 12, 2018

decimozs / verdant-vibes

A plant-focused e-commerce desktop application was created using Java, Java Swing, JUnit testing, and local database tailored specifically for plant-related enterprises.

  • Updated Jun 20, 2023

berksudan / Loan-Data-Report-with-AWS

Built a distributed system which completes several objectives with given data to generate loan reports using Amazon Web Services, Apache Spark, Java and Python.

  • Updated Nov 3, 2020

soloalex1 / sqlist

Uma aplicação de lista de tarefas como estudo de caso sobre o uso do SQLite no Android.

  • Updated Jun 28, 2019

alphaolomi / download-manager

A Robust Download Manager⏬ built using ☕Java

  • Updated Mar 26, 2022

siddeshbb / userpersonalisation-casestudy

User Personalisation Case Study

  • Updated Jun 20, 2019

YusufDagdeviren / Akbank-Web3-Practicum

Akbank Web3 Practicum için yapmış olduğum OOP case

  • Updated Sep 9, 2022

ManasMalla / PayPal-Clone-CaseStudy

PayPal (Payment Management System): A simple payment management system, inspired by PayPal, in the exact language in which the fin-tech giant started out.

  • Updated Apr 1, 2024

hkristanto / JHotDraw

  • Updated Jun 14, 2017

mohamedprojects / JavaCaseStudy

Étude de Cas de deux exemples (student, manager) en utilisant des diagrammes de classes pour illustrer les classes, les attributs et les méthodes

  • Updated Jan 9, 2022

OzerBey / FTTeknolojiPracticum

This repo contains case study of FtTechPracticum

  • Updated Sep 7, 2022

Dare-marvel / Big-Data-Analytics--BDA--

💾 Welcome to the Big Data Analytics Repository! 📚✨ Immerse yourself in a carefully curated reservoir of knowledge on Big Data Analytics. 🌐💡 Explore the intricacies of deriving insights from vast datasets and navigating powerful analytics tools. 🚀🔍

  • Updated Apr 3, 2024

KeYProject / DualPivotQuickSort

  • Updated Jun 13, 2023

Improve this page

Add a description, image, and links to the case-study topic page so that developers can more easily learn about it.

Curate this topic

Add this topic to your repo

To associate your repository with the case-study topic, visit your repo's landing page and select "manage topics."

Library homepage

  • school Campus Bookshelves
  • menu_book Bookshelves
  • perm_media Learning Objects
  • login Login
  • how_to_reg Request Instructor Account
  • hub Instructor Commons
  • Download Page (PDF)
  • Download Full Book (PDF)
  • Periodic Table
  • Physics Constants
  • Scientific Calculator
  • Reference & Cite
  • Tools expand_more
  • Readability

selected template will load here

This action is not available.

Engineering LibreTexts

13.5: Case Study- Designing a Basic GUI

  • Last updated
  • Save as PDF
  • Page ID 15144

  • Ralph Morelli & Ralph Wade
  • Trinity College

What elements make up a basic user interface? If you think about all of the various interfaces you’ve encountered—and don’t just limit yourself to computers—they all have the following elements:

Some way to provide help/guidance to the user.

Some way to allow input of information.

Some way to allow output of information.

Some way to control the interaction between the user and the device.

Think about the interface on a beverage machine. Printed text on the machine will tell you what choices you have, where to put your money, and what to do if something goes wrong. The coin slot is used to input money. There’s often some kind of display to tell you how much money you’ve inserted. And there’s usually a bunch of buttons and levers that let you control the interaction with the machine.

These same kinds of elements make up the basic computer interface. Designing a Graphical User Interface is primarily a process of choosing components that can effectively perform the tasks of input, output, control, and guidance.

In the programs we designed in the earlier chapters, we used two different kinds of interfaces. In the command-line interface, we used printed prompts to inform the user, typed commands for data entry and user control, and printed output to report results. Our GUI interfaces used JLabel s to guide and prompt the user, JTextField s and JTextArea s as basic input and output devices, and either JButton s or JTextField s for user control.

Let’s begin by building a basic GUI in the form of a Java application. To keep the example as close as possible to the GUIs we’ve already used, we will build it out of the following Swing components: JLabel , JTextField , JTextArea , and JButton .

The Metric Converter Application

Suppose the coach of the cross-country team asks you to write a Java application that can be used to convert miles to kilometers. The program should let the user input a distance in miles, and the program should report the equivalent distance in kilometers.

Before we design the interface for this, let’s first define a MetricConverter class that can be used to perform the conversions (Fig. 13.9). For now at least, this class’s only task will be to convert miles to kilometers, for which it will use the formula that 1 kilometer equals 0.62 miles:

Note that the method takes a double as input and returns a double . Also, by declaring the method static , we make it a class method, so it can be invoked simply by

Choosing the Components

Let’s now design a GUI to handle the interaction with the user. First, let’s choose Swing components for each of the four interface tasks of input, output, control, and guidance. For each component, it might be useful to refer back to Figure [fig-swing2-guis] to note its location in the Swing hierarchy.

A JLabel is a display area for a short string of text, an image, or both. Its AWT counterpart, the Label , cannot display images. A does not react to input. Therefore, it is used primarily to display a graphic or small amounts of static text. It is perfectly suited to serve as a prompt, which is what we will use it for in this interface.

A JTextField is a component that allows the user to edit a single line of text. It is identical to its AWT counterpart, the TextField . By using its getText() and setText() methods, a JTextField can be used for either input or output, or both. For this problem, we’ll use it to perform the interface’s input task.

A JTextArea is a multiline text area that can be used for either input or output. It is almost identical to the AWT TextArea component. One difference, however, is that a JTextArea does not contain scrollbars by default. For this program, we’ll use the JTextArea for displaying the results of conversions. Because it is used solely for output in this program, we’ll make it uneditable to prevent the user from typing in it.

Let’s use a JButton as our main control for this interface. By implementing the ActionListener interface we will handle the user’s action events.

Choosing the Top-Level Window

The next issue we must decide is what kind of top-level window to use for this interface. For applet interfaces, the top-level component would be a JApplet . For Java applications, you would typically use a JFrame as the top-level window. Both of these classes are subclasses of Container , so they are suitable for holding the components that make up the interface (Fig. [fig-swing1-guis] ).

Also, as noted earlier, JApplet s and JFrame s are both examples of heavyweight components, so they both have windows associated with them. To display a JFrame we just have to give it a size and make it visible. Because a frame runs as a stand-alone window, not within a browser context, it should also be able to exit the application when the user closes the frame.

Designing a Layout

The next step in designing the interface is deciding how to arrange the components so that they will be visually appealing and comprehensible, as well as easy to use.

Figure [fig-metricgui] shows a design for the layout. The largest component is the output text area, which occupies the center of the JFrame . The prompt, input text field, and control button are arranged in a row above the text area. This is a simple and straightforward layout.

Figure [fig-metricgui] also provides a containment hierarchy , also called a widget hierarchy , which shows the containment relationships among the various components. Although it might not seem so for this simple layout, the containment hierarchy plays an important role in showing how the various components are grouped in the interface. For this design, we have a relatively simple hierarchy, with only one level of containment. All of the components are contained directly in the JFrame .

Figure 13.11 shows the design of the Converter class, which extends the JFrame class and implements the ActionListener interface. As a JFrame subclass, a Converter can contain GUI components. As an implementor of the ActionListener interface, it also will be able to handle action events through the actionPerformed() method.

Figure [fig-converterclass] gives the implementation of the Converter class. Note the three packages that are imported. The first contains definitions of the Swing classes, and the other two contain definitions of AWT events and layout managers that are used in the program.

We have to do all initializing tasks in the constructor. First, we have to set the JFrame ’s layout to FlowLayout . A layout manager is the object that is responsible for sizing and arranging the components in a container so that the elements are organized in the best possible manner. A flow layout is the simplest arrangement: The components are arranged left to right in the window, wrapping around to the next “row” if necessary.

Second, note the statements used to set the layout and to add components directly to the JFrame . Instead of adding components directly to the JFrame , we must add them to its content pane:

A content pane is a JPanel that serves as the working area of the JFrame . It contains all of the frame’s components. Java will raise an exception if you attempt to add a component directly to a JFrame .

The JFrame and all the other top-level Swing windows have an internal structure made up of several distinct objects that can be manipulated by the program. Because of this structure, GUI elements can be organized into different layers within the window to create many types of sophisticated layouts. Also, one layer of the structure makes it possible to associate a menu with the frame.

Finally, note how the Converter frame is instantiated, made visible, and eventually exited in the application’s main() method:

It is necessary to set both the size and visibility of the frame, since these are not set by default. Because we are using a FlowLayout , it is especially important to give the frame an appropriate size. Failure to do so can cause the components to be arranged in a confusing way and might even cause some components to not appear in the window. These are limitations we will fix when we learn how to use some of the other layout managers.

Inner Classes and Adapter Classes

In this section we introduce two new language features, inner classes and adapter classes , which are used in the main() method shown above to handle the closing of the Converter application’s window when the program is exited:

This code segment provides a listener that listens for window closing events. When such an event occurs, it exits the application by calling System.exit() .

The syntax used here is an example of an anonymous inner class . An inner class is a class defined within another class. The syntax is somewhat ugly, because it places the class definition right where a reference to a window listener object would go. In effect what the code is doing is defining a subclass of WindowAdapter and creating an instance of it to serve as a listener for window closing events.

Anonymous inner classes provide a useful way of creating classes and objects on the fly to handle just this kind of listener task. The syntax used actually enables us to write one expression that both defines a class and creates an instance of it to listen for window closing events. The new subclass has local scope limited here to the main() method. It is anonymous, meaning we aren’t even giving it a name, so you can’t create other instances of it in the program. Note that the body of the class definition is placed right after the new keyword, which takes the place of the argument to the addWindowListener() method. For more details on the inner and anonymous classes, see Appendix F.

An adapter class is a wrapper class that implements trivial versions of the abstract methods that make up a particular interface. (Remember from Chapter 4 that a wrapper class contains methods for converting primitive data into objects and for converting data from one type to another.)

The WindowAdapter class implements the methods of the WindowListener interface. When you implement an interface, such as ActionListener , you must implement all the abstract methods defined in the interface. For ActionListener there’s just one method, the actionPerformed() method, so we can implement it as part of our applet or frame class. However, we want to use only one of the seven methods available in the WindowListener interface, the windowClosing() method, which is the method implemented in the anonymous inner class:

The WindowAdapter is defined simply as

Note that each method is given a trivial implementation (). To create a subclass of WindowAdapter , you must override at least one of its trivially implemented methods.

Another way to manage the application’s window closing event is to define a subclass of WindowAdapter :

Given this class, we can then place the following statement in Converter ’s main() method:

This is somewhat more familiar looking than the inner class construct. If you prefer this way of handling things, you can use this method in place of the inner classes here and in other examples.

GUI Design Critique

Figure 13.13 shows the converter interface. Although our basic GUI design satisfies the demands of input, output, control, and guidance, it has a few significant design flaws.

First, it forces the user to manually clear the input field after each conversion. Unless it is important that the user’s input value remain displayed until another value is entered, this is just an inconvenience to the user. In this case, the user’s input value is displayed along with the result in the JTextArea , so there’s no reason not to clear the input text field:

A second problem with our design is that it forces the user to switch between the keyboard (for input) and the mouse (for control). Experienced users will find this annoying. An easy way to fix this problem is to make both the JTextField and the JButton serve as controls. That way, to get the program to do the conversion, the user can just press the Enter key after typing a number into the text field.

To give the interface this type of control, we only need to add an ActionListener to the JTextField during the initialization step:

A JTextField generates an ActionEvent whenever the Enter key is pressed. We don’t even need to modify the actionPerformed() method, since both controls will generate the same action event. This will allow users who prefer the keyboard to use just the keyboard.

Given that the user can now interact with the interface with just the keyboard, a question arises over whether we should keep the button at all. In this case, it seems justifiable to keep both the button and the text field controls. Some users dislike typing and prefer to use the mouse. Also, having two independent sets of controls is a desirable form of redundancy. You see it frequently in menu-based systems that allow menu items to be selected either by mouse or by special control keys.

Another deficiency in the converter interface is that it doesn’t round off its result, leading sometimes to numbers with 20 or so digits. Develop Java code to fix this problem.

Give an example of desirable redundancy in automobile design.

Extending the Basic GUI: Button Array

Suppose the coach likes our program but complains that some of the folks in the office are terrible typists and would prefer not to have to use the keyboard at all. Is there some way we could modify the interface to accommodate these users?

This gets back to the point we were just making about incorporating redundancy into the interface. One way to satisfy this requirement would be to implement a numeric keypad for input, similar to a calculator keypad. Regular JButton s can be used as the keypad’s keys. As a user clicks keypad buttons, their face values—0 through 9—are inserted into the text field. The keypad will also need a button to clear the text field and one to serve as a decimal point.

This new feature will add 12 new JButton components to our interface. Instead of inserting them into the JFrame individually, it will be better to organize them into a separate panel and to insert the entire panel into the frame as a single unit. This will help reduce the complexity of the display, especially if the keypad buttons can be grouped together visually. Instead of having to deal with 16 separate components, the user will see the keypad as a single unit with a unified function. This is an example of the abstraction principle, similar to the way we break long strings of numbers (1-888-889-1999) into subgroups to make them easier to remember.

Figure [fig-metricgui2] shows the revised converter interface design. The containment hierarchy shows that the 12 keypad JButton s are contained within a JPanel . In the frame’s layout, the entire panel is inserted just after the text area.

Incorporating the keypad into the interface requires several changes in the program’s design. Because the keypad has such a clearly defined role, let’s make it into a separate object by defining a KeyPad class (Fig. 13.15). The KeyPad will be a subclass of JPanel and will handle its own ActionEvent s. As we saw in Chapter 4, a JPanel is a generic container. It is a subclass of Container via the JComponent class (Fig. [fig-swing2-guis] ). Its main purpose is to contain and organize components that appear together on an interface.

In this case, we will use a JPanel to hold the keypad buttons. As you might recall from Chapter 4, to add elements to a JPanel , you use the add() method, which is inherited from Container . (A JApplet is also a subclass of Container via the Panel class.)

As a subclass of JPanel , the KeyPad will take care of holding and organizing the JButton s in the visual display. We also need some way to organize and manage the 12 keypad buttons within the program’s memory. Clearly, this is a good job for an array. Actually, two arrays would be even better, one for the buttons and one for their labels:

The label array stores the strings that we will use as the buttons’ labels. The main advantage of the array is that we can use a loop to instantiate the buttons:

This code should be placed in the KeyPad() constructor. It begins by instantiating the array itself. It then uses a for loop, bounded by the size of the array, to instantiate each individual button and insert it into the array. Note how the loop variable here, k , plays a dual role. It serves as the index into both the button array ( buttons ) and the array of strings that serves as the buttons’ labels ( labels ). In that way the labels are assigned to the appropriate buttons. Note also how each button is assigned an ActionListener and added to the panel:

An important design issue for our KeyPad object concerns how it will interact with the Converter that contains it. When the user clicks a keypad button, the key’s label has to be displayed in the Converter ’s text area. But because the text area is private to the converter, the KeyPad does not have direct access to it. To address this problem, we will use a Java interface to implement a . In this design, whenever a KeyPad button is pressed, the KeyPad object calls a method in the Converter that displays the key’s label in the text area.

Figure [fig-p493f1] provides a summary of the callback design. Note that the association between the Converter and the KeyPad is bi-directional. This means that each object has a reference to the other and can invoke the other’s public methods. This will be effected by having the Converter pass a reference to itself when it constructs the KeyPad :

Another important design issue is that the KeyPad needs to know the name of the callback method and the Converter needs to have an implementation of that method. This is a perfect job for an abstract interface:

The KeyPad can interact with any class that implements the KeyPadClient interface. Note that the KeyPad has a reference to the , which it will use to invoke the keypressCallback() method.

The implementation of KeyPad is shown in Figure 13.17. Note that its constructor takes a reference to a KeyPadClient and saves it in an instance variable. Its actionPerformed() method then passes the key’s label to the KeyPadClient ’s callback method.

Given the KeyPad design, we need to revise our design of the Converter class (Fig. [fig-p493f1] ). The Converter will now implement the KeyPadClient interface, which means it must provide an implementation of the keypressCallback() method:

Recall that whenever the KeyPad object calls the keypressCallback() method, it passes the label of the button that was pressed. The Converter object simply appends the key’s label to the input text field, just as if the user typed the key in the text field.

The complete implementation of this revised version of the interface is shown in Figure 13.18 on the next page. The appearance of the interface itself is shown in Figure 3.19.

Figure 3.19 shows that despite our efforts to group the keypad into a rectangular array, it doesn’t appear as a single entity in the interface itself, which indicates a layout problem. The default layout for our KeyPad (which is a JPanel ) is FlowLayout , which is not appropriate for a numeric keypad that needs to be arranged into a two-dimensional grid pattern, which is the kind of layout our design called for (Fig. [fig-metricgui2] ).

Fortunately, this flaw can easily be fixed by using an appropriate layout manager from the AWT. In the next version of the program, we employ the java.awt.GridLayout , which is perfectly suited for a two-dimensional keypad layout (Section 13.7.2).

The lesson to be learned from this example is that screen layout is an important element of an effective GUI. If not done well, it can undermine the GUI’s effort to guide the user toward the appointed tasks. If done poorly enough, it can even keep the user from doing the task at all.

case study in java

Welcome to the Clean Coders Java Case Study. This is Episode 1.

Over the next weeks and months, Micah and Uncle Bob will re-implement the cleancoders.com website in Java before your very eyes. You'll see them applying all the principles, patterns, and practices that you've been learning in the Clean Code series . But instead of learning about those principles, patterns, and practices, you'll see how they use them in real life.

The first episode is entitled Getting Nothing Done because in this episode they use the first acceptance tests in FitNesse to set up the infrastructure and facilities they need to start getting real stories implemented. They do finish one story, but it's the story of the null case.

So get ready for some fun and education and you watch these two seasoned professionals work together to create a web system in Java.

If you want to follow along with the code, you can find it on Github: https://github.com/cleancoders/CleanCodeCaseStudy

  • Software Developers
  • Java Developers

Java Development Case Studies And Success Stories

by Ideamotive Talent

Take a look at these Java case studies to see how our developers have served clients in numerous industries. With each project analysis, you’ll be able to shape a general impression about our developers, their experience, and their skills. Every time we’re making our best effort to enhance the clients’ business and strengthen their positions on the market.

Here, you’ll discover about:

  • Client’s business, the targets, and challenges they faced during the project’s implementation.
  • What results they expect from our company and why they’ve chosen us.
  • Our detailed step-by-step project analysis, specific methods, technologies, and tools we’ve used to succeed.
  • The major challenges our team has faced, and the solution we’ve chosen to resolve the client’s problem.
  • The final results our team has presented to the clients - what has been changed and the benefits our clients get with the outcome.

Napoli Gang: reinventing food delivery for a European delivery-based restaurant chain

How we developed a fast, scalable mobile solution from scratch for an estimated target audience of 10,000 users.

Napoli Gang

Food Service

im_napoli_gang_2880x1276_hero_desktop-01 (1)

JRPass: Marrying web development and business processes support

How to optimize booking system for a Japanese railway network and increase sales?

im_jrpass_2880x1276

TRAVELDUCK: building a marketplace for boutique adventure trips and activities

How we created a fully functional digital marketplace from scratch and helped the Client validate the business model for scaling up.

Travel, Marketplace

im_travelduck_2880x1276

There are hundreds of battle-proven experts in our Talent Network.

What our Clients say about us:

We’ve been extremely satisfied. We work with multiple partners, but they’re our main supplier because of the quality of their work.

hakonaroen

Håkon Årøen

Co-founder & CTO of Memcare

Ideamotive has a huge pool of talent. Don’t just settle for someone: find a person who understands your project and has the competencies you need.

julianpeterson

Julian Peterson

President, Luminate Enterprises

They understand and navigate the industry to deliver an outcome that will truly stand out. Despite a heavily saturated market, they’ve delivered creative solutions that I haven’t seen before.

adam buchanan

Adam Casole-Buchanan

President, Rierra INC

They are very flexible, providing a team of developers on short notice and scaling the size as needed. Their team meets tight deadlines, including some that only give them a few hours to do the work.

SylvainBernard

Sylvain Bernard

Event Manager, Swiss Federal Institute of Technology Lausanne

Startups , scale-ups and enterprises build their teams with Ideamotive

jrpass_dark-1

Other Java developers hiring and business resources:

Java Developers Interview Questions

Java Developer Job Description And Ad

Java Development Company

Java Freelancers

The Business Side of Java Development [Guide]

funds

Business registry data:

[email protected]

Most desired experts

Rated 4.9 / 5.0 by 25 clients for web development, mobile development and design services.

Java Case Study

  • First Online: 02 October 2022

Cite this chapter

case study in java

  • Quentin Charatan 5 &
  • Aaron Kans 6  

Part of the book series: Texts in Computer Science ((TCS))

1697 Accesses

You have now covered many aspects of the Java language. In this chapter we are going to take stock of what you have learnt by developing a Java application that draws upon all these topics. We will implement interfaces; we will catch and throw exceptions; we will make use of the collection classes in the java . util package; and we will store objects to file. We will also make use of many JavaFX components to develop an attractive graphical interface.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
  • Available as EPUB and PDF
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info
  • Durable hardcover edition

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

If you are developing a class from scratch that you wish to add into a package, your Java IDE can be used so that the package line is inserted into your code for you and the required directory structure is created. If you are using your Java IDE to revisit classes previously written outside of a package (as in this example), you may need to ensure that the resulting directory structure is reflected in the project you are working in. Refer to your IDE’s documentation for details about how to do this.

By default, the tabs you add will appear at the top left of the TabPane (as in Fig.  24.8 ). A setSide method can be used to choose an alternative side (the top right, the bottom, the left or the right).

Author information

Authors and affiliations.

School of Architecture, Computing and Engineering, University of East London, London, UK

Dr. Quentin Charatan

Dr. Aaron Kans

You can also search for this author in PubMed   Google Scholar

Corresponding author

Correspondence to Quentin Charatan .

1 Electronic supplementary material

Below is the link to the electronic supplementary material.

Supplementary file1 (ZIP 25 kb)

Rights and permissions.

Reprints and permissions

Copyright information

© 2022 Springer Nature Switzerland AG

About this chapter

Charatan, Q., Kans, A. (2022). Java Case Study. In: Programming in Two Semesters. Texts in Computer Science. Springer, Cham. https://doi.org/10.1007/978-3-031-01326-3_24

Download citation

DOI : https://doi.org/10.1007/978-3-031-01326-3_24

Published : 02 October 2022

Publisher Name : Springer, Cham

Print ISBN : 978-3-031-01325-6

Online ISBN : 978-3-031-01326-3

eBook Packages : Computer Science Computer Science (R0)

Share this chapter

Anyone you share the following link with will be able to read this content:

Sorry, a shareable link is not currently available for this article.

Provided by the Springer Nature SharedIt content-sharing initiative

  • Publish with us

Policies and ethics

  • Find a journal
  • Track your research

Chapter 51 Duke’s Bookstore Case Study Example

The Duke’s Bookstore example is a simple e-commerce application that illustrates some of the more advanced features of JavaServer Faces technology in combination with Contexts and Dependency Injection for the Java EE Platform (CDI), enterprise beans, and the Java Persistence API. Users can select books from an image map, view the bookstore catalog, and purchase books. No security is used in this application.

The following topics are addressed here:

Design and Architecture of Duke's Bookstore

The Duke's Bookstore Interface

Running the Duke's Bookstore Case Study Application

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices

Scripting on this page tracks web page traffic, but does not change the content in any way.

Part XII Case Studies

Part XII presents case studies that use a variety of Java EE technologies. This part contains the following chapters:

Chapter 61, "Duke’s Bookstore Case Study Example"

Chapter 62, "Duke’s Tutoring Case Study Example"

Chapter 63, "Duke’s Forest Case Study Example"

Beta Draft (Pre-General Availability)

English

Java Programming Case Study Examples

  • in Talent Insight

If you are an HR professional looking for talented Java programmers, then you are in the right place. This article will provide you with some great case study examples that showcase the skills and expertise of top Java programmers.

Importance of Case Studies for HR Professionals

Case studies are an essential tool for HR professionals when hiring top talent. They provide a deeper understanding of a candidate’s skills, knowledge, and experience, which is not always possible through resumes or interviews. By reviewing case studies, HR professionals can evaluate a candidate’s ability to solve complex problems and develop innovative solutions.

Here are some excellent case study examples that demonstrate the skills and expertise of top Java programmers:

  • Google Maps : Google Maps is one of the most popular navigation applications in the world. It is built using Java and provides real-time traffic updates, street views, and satellite imagery. Google Maps is an excellent example of how Java programming can be used to develop complex and innovative solutions.
  • Amazon : Amazon is the world’s largest online retailer, and its website is built using Java. The website handles millions of transactions every day, and its success is a testament to the reliability and scalability of Java programming.
  • Netflix : Netflix is a streaming platform that delivers movies and TV shows to millions of users worldwide. It uses Java programming to create personalized recommendations, manage user profiles, and optimize streaming quality.

Why Choose Algobash?

At Algobash, we specialize in connecting HR professionals with top Java programmers. Our platform features a comprehensive database of talented programmers who have been rigorously tested and vetted. By using Algobash, you can save time and money while finding the perfect candidate for your organization.

Online Psychological Test Platform: Explore Employee Potential More Efficiently

Psychological tests are an important tool in employee selection, psychometric test for internal employees.

Secure Coding: Principles and Practices by Mark G. Graff, Kenneth R. van Wyk

Get full access to Secure Coding: Principles and Practices and 60K+ other titles, with a free 10-day trial of O'Reilly.

There are also live events, courses curated by job role, and more.

2.3. Case Study: The Java Sandbox

An excellent example of a system that was intended from scratch to be secure is the Java "sandbox." Java certainly has had its share of security vulnerabilities. But it remains an excellent example of the principle that many mistakes can be designed out at by selecting an appropriate security model.

Let's let the chief security architect of Java, Sun's Li Gong, explain the idea of the sandbox:

The original security model provided by the Java platform is known as the sandbox model , which [provided] a very restricted environment in which to run untrusted code obtained from the open network... [L]ocal code is trusted to have full access to vital system resources (such as the filesystem) while downloaded remote code (an applet) is not trusted and can access only the limited resources provided inside the sandbox... Overall security is enforced through a number of mechanisms. First of all, the language is designed to be type-safe and easy to use. The hope is that the burden on the programmer is such that the likelihood of making subtle mistakes is lessened compared with using other programming languages such as C or C++. Language features such as automatic memory management, garbage collection, and range checking on strings and arrays are examples of how the language helps the programmer to write safe code. Second, compilers and a bytecode verifier ensure that only legitimate Java bytecodes are executed. The bytecode verifier, together with the Java ...

Get Secure Coding: Principles and Practices now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.

Don’t leave empty-handed

Get Mark Richards’s Software Architecture Patterns ebook to better understand how to design components—and how they should interact.

It’s yours, free.

Cover of Software Architecture Patterns

Check it out now on O’Reilly

Dive in for free with a 10-day trial of the O’Reilly learning platform—then explore all the other resources our members count on to build skills and solve problems every day.

case study in java

  • Java Arrays
  • Java Strings
  • Java Collection
  • Java 8 Tutorial
  • Java Multithreading
  • Java Exception Handling
  • Java Programs
  • Java Project
  • Java Collections Interview
  • Java Interview Questions
  • Spring Boot
  • Multithreading in Java
  • Lifecycle and States of a Thread in Java
  • Main thread in Java
  • Java Concurrency - yield(), sleep() and join() Methods
  • Inter-thread Communication in Java
  • Java.lang.Thread Class in Java
  • What does start() function do in multithreading in Java?
  • Java Thread Priority in Multithreading
  • Joining Threads in Java
  • Naming a thread and fetching name of current thread in Java
  • Synchronization in Java
  • Method and Block Synchronization in Java

Producer-Consumer solution using threads in Java

  • Thread Pools in Java
  • Semaphore in Java
  • Java.util.concurrent.Semaphore Class in Java
  • CountDownLatch in Java
  • Deadlock in Java Multithreading
  • Daemon Thread in Java
  • Reentrant Lock in Java
  • Java.util.concurrent.CyclicBarrier in Java
  • Callable and Future in Java
  • Java.lang.Runtime class in Java
  • Output of Java program | Set 16 (Threads)

In computing, the producer-consumer problem (also known as the bounded-buffer problem) is a classic example of a multi-process synchronization problem. The problem describes two processes, the producer and the consumer, which share a common, fixed-size buffer used as a queue. 

  • The producer’s job is to generate data, put it into the buffer, and start again.
  • At the same time, the consumer is consuming the data (i.e. removing it from the buffer), one piece at a time.

Problem   To make sure that the producer won’t try to add data into the buffer if it’s full and that the consumer won’t try to remove data from an empty buffer.

Solution  The producer is to either go to sleep or discard data if the buffer is full. The next time the consumer removes an item from the buffer, it notifies the producer, who starts to fill the buffer again. In the same way, the consumer can go to sleep if it finds the buffer to be empty. The next time the producer puts data into the buffer, it wakes up the sleeping consumer.  An inadequate solution could result in a deadlock where both processes are waiting to be awakened.  Recommended Reading- Multithreading in JAVA , Synchronized in JAVA , Inter-thread Communication

Implementation of Producer Consumer Class  

  • A LinkedList list – to store list of jobs in queue.
  • A Variable Capacity – to check for if the list is full or not
  • A mechanism to control the insertion and extraction from this list so that we do not insert into list if it is full or remove from it if it is empty.

Note: It is recommended to test the below program on a offline IDE as infinite loops and sleep method may lead to it time out on any online IDE   

Output:  

Important Points   

  • In PC class (A class that has both produce and consume methods), a linked list of jobs and a capacity of the list is added to check that producer does not produce if the list is full.
  • Also, we have an infinite outer loop to insert values in the list. Inside this loop, we have a synchronized block so that only a producer or a consumer thread runs at a time.
  • An inner loop is there before adding the jobs to list that checks if the job list is full, the producer thread gives up the intrinsic lock on PC and goes on the waiting state.
  • If the list is empty, the control passes to below the loop and it adds a value in the list.
  • Inside, we also have an inner loop which checks if the list is empty.
  • If it is empty then we make the consumer thread give up the lock on PC and passes the control to producer thread for producing more jobs.
  • If the list is not empty, we go round the loop and removes an item from the list.
  • In both the methods, we use notify at the end of all statements. The reason is simple, once you have something in list, you can have the consumer thread consume it, or if you have consumed something, you can have the producer produce something.
  • sleep() at the end of both methods just make the output of program run in step wise manner and not display everything all at once so that you can see what actually is happening in the program.

Exercise :  

  • Readers are advised to use if condition in place of inner loop for checking boundary conditions.
  • Try to make your program produce one item and immediately after that make the consumer consume it before any other item is produced by the producer.

Reference – https://en.wikipedia.org/wiki/Producer%E2%80%93consumer_problem

Please Login to comment...

Similar reads.

advertisewithusBannerImg

Improve your Coding Skills with Practice

 alt=

What kind of Experience do you want to share?

Decode School

  • OOPS CASE STUDY 1

Sept. 27, 2019, 6:03 a.m. | OOPS in Java

Instructions to students:

1.       Read the Problem Description carefully and understand the Scenario and Class Diagram.

2.       Read the implementation details and understand the requirements you need to implement.

3.    Demo.java file contains all the necessary classes and the classes are partially coded to implement the given scenario.

Guidelines:

1.       You should only code your program at the space mentioned as “//Replace Your Code”.

2.       Your Code should satisfy the requirements specified in the Implementation Details.

3.       Don’t add additional methods in any class.

NOTE: NOT adhering to the above instructions and guidelines may lead to drastic reduction in your score even if the code is executing without any errors

Problem Description:

“A to Z Fruit Shop” is a growing fruit shop in Coimbatore city. Since they are offering quality and fresh fruits to customers in best price, their customer strength is increasing tremendously. In this regard they need billing software to provide a fast and accurate service. Billing software also supports high to maintain sales data.

Business Rules:

1.       Every item stock should be verified for availability before billing.

2.       5% discount should be provided for purchase more than Rs. 500/-

3.       All fruits except banana are selling for price-per-kilo gram.

4.       Selling Banana for price-per-piece.

case study in java

1.    Don’t add additional instance variable in the given class.

1.       2.   Do Type conversions wherever it is necessary.

        3. Don’t make change in the Demo Class.

Implementation Details:

            Fruit Class

                        This class is already coded for you.

Fruitingms Class

Ø   Write constructor method fruitingms() for this class.

Ø   Write Check _availability() method which takes “ need ” in kilograms as input and returns false if available_kgs is less than “ need” else return true.  

Ø  Write update_availability () method which takes “need” in kilograms as input and reduce this “need” from available_kgs .

Fruitinpcs Class

Ø   Write constructor method fruitinpcs() for this class.

Ø   Write Check _availability() method which takes “ need ” in pieces as input and returns false if available_pcs is less than “ need” else return true.

Ø   Write update_availability () method which takes “need” in pieces as input and reduce this “need” from available_pcs.

Ø   Constructor is already coded for you.

Ø   Bill() method

Ø   Validate availability of fruit before billing

Ø   Calculate amount by product of unit and price

Ø   Provide discount by calling discount() if amount is greater than 500

Ø   Update availability of fruit after billing

                                            Ø    Discount method calculates discount of 5%.  

Demo Class:

                            Ø  This Class is a Starter Class.

         Ø  Code is already provided for you.

         Ø  You can modify the class for testing purpose.

        Ø  This class will not be evaluated.

This Code includes solution for the above question. The code below comment line // write your code here is the solution.

Solution Code:

      class Fruit

     {

      privateint code;

      private String name;

      staticint counter = 1000;

      Fruit(String name)

      this.name = name;

      }

        classFruitingms extends Fruit

      {

       private double available_kgs;

       private double price_per_kg;

       Fruitingms(String name, double available_kgs,doubleprice_per_kg)

       super(name);

       this.available_kgs = available_kgs;

       this.price_per_kg = price_per_kg;

       }

        public double getprice()

         returnprice_per_kg;

          publicbooleancheckavailability(double need)

       {

          //write your code here

        if(available_kgs<need)

        return false;

        }

        return true;

         public void updateavailability(double need)

         //write your code here

         available_kgs = available_kgs - need;

         }

          classFruitinpcs extends Fruit

        {

         private double available_pcs;

         private double price_per_piece;

          Fruitingms(String name, double available_pcs,doubleprice_per_piece)

        super(name);

        this.available_pcs = available_pcs;

        this.price_per_piece = price_per_piece;

        returnprice_per_piece;

      }

        publicbooleancheckavailability(double need)

      {

        //write your code here

       if(available_pcs<need)

         return true;

          public void updateavailability(double need)

         available_pcs = available_pcs - need;

         }  

          class Sale

          privateint code;

          private Fruit fobj;

          private double unit;

          private double amount;

          staticint counter = 2000;

          Sale(Fruit fobj,double unit)

         {

          this.fobj = fobj;

          this.unit = unit;

          }

           public double Bill()

           //write your code here

          if(!fobj.checkavailability(unit))

           System.out.println("Item not available");

           return false;    

           }

            amount = fobj.getprice() * unit;

            if(amount > 500)

           {

            amount = discount();

            }

             fobj.pdateavailability(unit);

            return amount;

            }

            public double discount()

          {

            int disc = amount/100 * 5;

            amount = amount - disc;

           class Demo

           public static void main(String args[])

            Fruit fobj = new Fruitingms("apple",50.6,80.0);

            Sale s = new Sale(fobj,2.0);

            System.out.println(s.bill());

             Fruit fobj1 = new Fruitinpcs("banana",200,3.0);

            Sale s1 = new Sale(fobj,10);

            System.out.println(s1.bill());

           

Related Posts

Email id for digital training, decode school.

Dexar Code School or shortly Decode School is a platform to learn Programs and foundations of Comptuter Science. It enables a 360 ° and depth learning through examples and excercises.

Beginner Links

  • Guessing Game Programs
  • Pattern Programs
  • Number Pattern Programs
  • Logic Building in C
  • Logic Building in Python
  • Python Programming Examples
  • C Programming Examples
  • Java Programming Examples

© Copyright 2017-DEXAR CODE SCHOOL. Design by: uiCookies

DECODE SCHOOL

  • C Programming
  • Python Programming
  • Java Programming
  • Python Logic Building
  • Problem Solving using Java
  • Text Mining
  • Python Tutorial
  • OOPS in Java
  • Database Management
  • Operating Systems

Session Detail

IMAGES

  1. Case Statement in Java

    case study in java

  2. Case Study (Java)

    case study in java

  3. Case Statement in Java

    case study in java

  4. Java

    case study in java

  5. Case Study

    case study in java

  6. (PDF) A CASE STUDY: JAVA IS SECURE PROGRAMMING LANGUAGE

    case study in java

VIDEO

  1. Switch Case in Core Java

  2. CASE STAEMENT IN JAVA SCRIPT

  3. Mastering Java Interview Questions: Common Challenges and Expert Answers

  4. 1 Course Introduction

  5. Switch case practice questions ( Part- 1)of Java

  6. How to attempt :Scenario/Case based JAVA programming in EXAMS

COMMENTS

  1. List of Examples and Case Studies

    O'Reilly members experience books, live events, courses curated by job role, and more from O'Reilly and nearly 200 top publishers. List of Examples and Case Studies 2.1 Welcome 2.2 Drawing a flag 2.3 Curio Store 2.4 Displaying a warning 2.5 Curio shop table 2.6 Fleet timetables 3.1 Math class investigation …. - Selection from Java Gently ...

  2. case-study · GitHub Topics · GitHub

    A case-study that shows how the Smart Contract Locator (SCL), the Smart Contract Description Language (SCDL), and the Smart Contract Invocation Protocol (SCIP) can be used in combination to support the integration of heterogeneous multi-blockchain setups into client applications.

  3. Case Studies

    Case Studies. Part IX presents case studies that use a variety of Java EE technologies. This part contains the following chapters: Chapter 51, Duke's Bookstore Case Study Example. Chapter 52, Duke's Tutoring Case Study Example. Chapter 53, Duke's Forest Case Study Example.

  4. 13.5: Case Study- Designing a Basic GUI

    Choosing the Top-Level Window. The next issue we must decide is what kind of top-level window to use for this interface. For applet interfaces, the top-level component would be a JApplet.For Java applications, you would typically use a JFrame as the top-level window. Both of these classes are subclasses of Container, so they are suitable for holding the components that make up the interface ...

  5. Case Study: Build and Run a Streaming Application Using an ...

    Select the Create Stream button and name the stream http-jdbc. To deploy the stream, click on the play button: Accept the default deployment properties and click Deploy stream at the bottom of the page. Click on the Refresh button as necessary. After a minute or so, you should see our stream is deployed.

  6. PDF 6 Java as a systems programming language: three case studies

    Java is the newest in a long line of systems programming languages. This paper looks at what makes it special and backs the findings up with three case studies. The projects exercise Java to the full - its features and APis. first is a Web Computing Skeleton for remote execution of collaborative programs.

  7. Java Case Study, Episode 1

    Welcome to the Clean Coders Java Case Study. This is Episode 1. Over the next weeks and months, Micah and Uncle Bob will re-implement the cleancoders.com website in Java before your very eyes. You'll see them applying all the principles, patterns, and practices that you've been learning in the Clean Code series.

  8. Java Development Case Studies And Success Stories

    Java Development Case Studies And Success Stories. Take a look at these Java case studies to see how our developers have served clients in numerous industries. With each project analysis, you'll be able to shape a general impression about our developers, their experience, and their skills. Every time we're making our best effort to enhance ...

  9. Java Case Study

    First we will take a look at Java's package facility, which allows us to bundle together related classes, because we are going to make use of this in our case study. Second, we will describe Javadoc, which—as we briefly mentioned in Chap. 13 —is a tool for professionally documenting Java classes.

  10. Duke's Bookstore Case Study Example

    Chapter 51Duke's Bookstore Case Study Example. The Duke's Bookstore example is a simple e-commerce application that illustrates some of the more advanced features of JavaServer Faces technology in combination with Contexts and Dependency Injection for the Java EE Platform (CDI), enterprise beans, and the Java Persistence API.

  11. Case Studies

    Part XII Case Studies. Part XII presents case studies that use a variety of Java EE technologies. This part contains the following chapters: Chapter 61, "Duke's Bookstore Case Study Example". Chapter 62, "Duke's Tutoring Case Study Example". Chapter 63, "Duke's Forest Case Study Example".

  12. Java Programming Case Study Examples

    Java Programming Case Study Examples. Here are some excellent case study examples that demonstrate the skills and expertise of top Java programmers: Google Maps: Google Maps is one of the most popular navigation applications in the world. It is built using Java and provides real-time traffic updates, street views, and satellite imagery.

  13. Case Study in java

    Case Study in java. Ask Question Asked 13 years, 3 months ago. Modified 2 years, 11 months ago. Viewed 1k times -2 Could anyone provide me information where I can find the case study for java coding and design practice. Basically looking for a case studies which resemble to the real time application like pet Store application, flight search ...

  14. Producer-Consumer Problem With Example in Java

    If the queue is empty, the consumer waits for a message to be produced. When the consumer wakes up from waiting, it checks the running flag. If the flag is false, then it breaks out of the loop. Otherwise, it reads a message from the queue and notifies the producer that it's waiting in the "full queue" state.

  15. Java

    Java - Case Studywatch more videos at https://www.tutorialspoint.com/videotutorials/index.htmLecture By: Mr. Tushar Kale, Tutorials Point India Private Limited

  16. Top 50 Java Project Ideas For Beginners & Advanced

    7. Library Management System. Learning Management System, this project build on Java is a great way to update the record, monitor and add books, search for the required ones, taking care of the issue date and return date. It comes with basic features like creating a new record and updating and deleting it.

  17. IC211: OOP Case Study

    Catching an Exception. There are already several things we might do that cause exceptions to be thrown. You can see two by playing with the above program: indexing an array out of bounds, and calling Integer.parseInt () with a string that cannot be interpreted as an integer. So let's see if we can catch these exceptions.

  18. Java.io in nutshell: 22 case studies

    Case 1: Two constants in File. Case 2: Delete a file. Case 3: Create a directory. Case 4: List files and directories in a given directory. Case 5: Tests whether a file is a file. Case 6: Write to a RandomAccessFile. Case 7: Write bytes to a file. Case 8: Append bytes to a file. Case 9: Read bytes from a file.

  19. Case Study: The Java Sandbox

    Case Study: The Java Sandbox. An excellent example of a system that was intended from scratch to be secure is the Java "sandbox." Java certainly has had its share of security vulnerabilities. But it remains an excellent example of the principle that many mistakes can be designed out at by selecting an appropriate security model.

  20. Producer-Consumer solution using threads in Java

    Solution. The producer is to either go to sleep or discard data if the buffer is full. The next time the consumer removes an item from the buffer, it notifies the producer, who starts to fill the buffer again. In the same way, the consumer can go to sleep if it finds the buffer to be empty. The next time the producer puts data into the buffer ...

  21. Java Development

    Selected Success Stories from Our 3,600-Project Portfolio. Leveraging 25 years of experience in Java, ScienceSoft offers comprehensive Java application development services. We have successfully completed over 120 large-scale Java projects, encompassing enterprise applications, industry-specific systems (EHR, online banking, POS), web portals ...

  22. OOPS CASE STUDY 1

    OOPS CASE STUDY 1. 1. Read the Problem Description carefully and understand the Scenario and Class Diagram. 2. Read the implementation details and understand the requirements you need to implement. 3. Demo.java file contains all the necessary classes and the classes are partially coded to implement the given scenario.

  23. PDF Case Study: Object-oriented Refactoring of Java Programs using Graph

    2.1 Setting of the Case Study Java Source Code All input programs considered for refactoring for TTC are fully functioning (although, abstract) Java programs built for the very purpose of checking the correct and thorough implementation of the given refactoring. 5 operations. Some test input programs are openly available and will be also de-