Create a new project, cardCredit-exercise, within BlueJ. Create a class, CreditCard, that contains the following fields: • credit - The current available card credit of type double • creditLimit - The card credit limit of type double • numericPin - The (numeric) pin of the credit card of type int • isLoggedIn - A field of type boolean that indicates whether the user is logged in or out Define a constructor that takes two parameters (of the appropriate type) and sets the values of creditLimit and numericPin accordingly. In the constructor the credit field should be initially set equal to the credit limit and the value of isLoggedIn should be set to false. Define the method logIn that takes a pin as a parameter and if this pin is correct sets the isLoggedIn field to true, otherwise print a message to the user indicating that the inserted pin is wrong. Define the method logOut that sets the value of the field isLoggedIn to false. Define an accessor method getCurrentCredit that, only when the user is logged in, returns the available credit of the card, and a method getCurrentBalance that returns the balance of the card. (Please note that these methods should always return a double, even if you are not logged in. In this case just pick a “meaningful” value) Finally, define the methods withdraw and deposit that take an amount of money as parameter (of the appropriate type), whose effect is to increase or decrease the available credit of the card only when the user is logged in. In the withdraw method, it should be checked that the available credit of the card is sufficient. Add a check both to the deposit method and withdraw method to prevent a negative value from being passed as argument. Test that the class works as you would expect it to by creating some CreditCard objects within BlueJ and calling

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

Create a new project, cardCredit-exercise, within BlueJ. Create a class, CreditCard, that contains the following

fields:

• credit - The current available card credit of type double

• creditLimit - The card credit limit of type double

• numericPin - The (numeric) pin of the credit card of type int

• isLoggedIn - A field of type boolean that indicates whether the user is logged in or out

Define a constructor that takes two parameters (of the appropriate type) and sets the values of creditLimit and

numericPin accordingly. In the constructor the credit field should be initially set equal to the credit limit and the

value of isLoggedIn should be set to false.

Define the method logIn that takes a pin as a parameter and if this pin is correct sets the isLoggedIn field to true,

otherwise print a message to the user indicating that the inserted pin is wrong. Define the method logOut that sets the

value of the field isLoggedIn to false.

Define an accessor method getCurrentCredit that, only when the user is logged in, returns the available credit of the

card, and a method getCurrentBalance that returns the balance of the card. (Please note that these methods should

always return a double, even if you are not logged in. In this case just pick a “meaningful” value)

Finally, define the methods withdraw and deposit that take an amount of money as parameter (of the appropriate

type), whose effect is to increase or decrease the available credit of the card only when the user is logged in. In the

withdraw method, it should be checked that the available credit of the card is sufficient. Add a check both to the

deposit method and withdraw method to prevent a negative value from being passed as argument.

Test that the class works as you would expect it to by creating some CreditCard objects within BlueJ and calling the

respective method

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY