Java: An Introduction to Problem Solving and Programming (7th Edition)
Java: An Introduction to Problem Solving and Programming (7th Edition)
7th Edition
ISBN: 9780133766264
Author: Walter Savitch
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Question
Book Icon
Chapter 5, Problem 1E
Expert Solution
Check Mark
Program Plan Intro

Unified Modeling Language (UML)

Unified Modeling Language (UML) is a modeling language in software engineering, which is used to visualize the design of the proposing system.

  • In software development life cycle, it comes under the “documenting the program” phase.
    • UML is used to document the developing system; this documentation helps the end user to understand the whole project.
  • It visualizes all the components used in the developed object-oriented software; it shows all the elements and its relation.

Class diagram:

Class diagram is a static model which represents the system’s static structure and its relationship using attributes, relationships, objects, and operations.

  • The relationship between the classes in the class diagram is called association.
  • It is represented by drawing a line called association path between classes and placing the labels in between the association path.
  • The instance of one class can be associated with more than one instance of another class and it is referred as multiplicity.

Steps to create class diagram:

  • Identify objects
  • Identify the attributes and behaviors
  • Draw association between the classes.

Representing the class diagram:

  • Every class in the class diagram is represented using a rectangle.
  • The rectangle is divided into three parts,
    • The first part contains the name of the class
    • The middle part contains the attributes and derived attributes
    • The last part contains the methods.
Class name

-Attribute name

+Operation name()

Explanation of Solution

Attributes:

  • Initially, identify the reasonable attributes for “CreditCard” class.
  • The “CreditCard” contains the card number, card name, expiry date for card, and so on.
  • So, let us take the followings are the attributes for “CreditCard” class.
    • “cardNo”
    • “name”
    • “cardExpiryDate”
Expert Solution
Check Mark

Explanation of Solution

Behaviors:

  • Initially, identify the reasonable behaviors for “CreditCard” class.
  • The “CreditCard” contains the “getCredit”, “getPurchase” and so on.
  • So, let us take the followings are the behaviors for “CreditCard” class.
    • “getCredit()”
    • “getPurchase()”
Expert Solution
Check Mark

Explanation of Solution

The UML class diagram for credit card is shown below:

The “CreditCard” class is shown in the following class diagram:

Java: An Introduction to Problem Solving and Programming (7th Edition), Chapter 5, Problem 1E , additional homework tip  1

Explanation:

In the above diagram,

  • The class name is “CreditCard”.
  • The “cardNo”, “name”, and “cardExpiryDate” are attributes of “CreditCard” class.
  • The “getCredit()” and “getPurchase()” are methods or operation name of “CreditCard” class.
    • “getCredit()” method is used to gets the credit card amount from bank.
    • “getPurchase()” is used to purchase the products by using the credit card.

Examples of objects of this “CreditCard”class:

First object:

 The first object is “customer1” for this “CreditCard” class is shown below:

Java: An Introduction to Problem Solving and Programming (7th Edition), Chapter 5, Problem 1E , additional homework tip  2

Explanation:

In the above diagram,

  • The “customer1” object for “CreditCard” class.
  • Assign the “cardNo” as “123456”, “name” as “XXXX” and “cardExpiryDate” as “03/02/2001” are the attributes of the “CreditCard” class.

Second object:

 The second object is “customer2” for this “CreditCard” class is shown below:

Java: An Introduction to Problem Solving and Programming (7th Edition), Chapter 5, Problem 1E , additional homework tip  3

Explanation:

In the above diagram,

  • The “customer2” object for “CreditCard” class.
  • Assign the “cardNo” as “234578”, “name” as “YYYY” and “cardExpiryDate” as “12/11/2022” are the attributes of the “CreditCard” class.

Third object:

 The third object is “customer3” for this “CreditCard” class is shown below:

Java: An Introduction to Problem Solving and Programming (7th Edition), Chapter 5, Problem 1E , additional homework tip  4

Explanation:

In the above diagram,

  • The “customer3” object for “CreditCard” class.
  • Assign the “cardNo” as “341579”, “name” as “ZZZZ” and “cardExpiryDate” as “01/02/2010” are the attributes of the “CreditCard” class.

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
08:30
Students have asked these similar questions
Need help writing code to answer this question in Python! (image attached)
Need help with python code! How do I simplify my code for a beginner to understand, simple fixed format and centering? Such as:  print(f"As an int variable: {age_int:^7}") print(f"In numeric binary: {age_int:^7b}") My Code:name = input("Enter your name: ")print(f"In text name is: {' '.join(name)}")decimal_values = []binary_values = []for letter in name:   ascii_val = ord(letter)   binary_val = format(ascii_val, '08b')   decimal_values.append(str(ascii_val))   binary_values.append(binary_val)# Loop through each letter:print(f"In ASCII decimal: {' '.join(decimal_values)}")print(f"In ASCII binary: {' '.join(binary_values)}")# Ageage_str = input("Enter your age: ")age_int = int(age_str)print(f"As a string \"{age_str}\": {' '.join(age_str)}")age_decimal_values = []age_binary_values = []for digit in age_str:   ascii_val = ord(digit)   binary_val = format(ascii_val, '07b')   age_decimal_values.append(str(ascii_val))   age_binary_values.append(binary_val)print(f"In ASCII decimal: {'…
Don't use chatgpt or any other AI

Chapter 5 Solutions

Java: An Introduction to Problem Solving and Programming (7th Edition)

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Cengage Learning
Introduction to Classes and Objects - Part 1 (Data Structures & Algorithms #3); Author: CS Dojo;https://www.youtube.com/watch?v=8yjkWGRlUmY;License: Standard YouTube License, CC-BY