Question

In a header file named 'Card.h' within the namespace LB3, define a class named Card that must contain: - A private char field named suit. - A private char field named symbol. - A public default constructor that assigns 'X' to both fields. - A public copy constructor. - A public assignment operator. - A public empty destructor. - A public constant getter method for suit named Suit(). - A public constant getter method for symbol named Symbol(). - A public setter method for suit named SetSuit() that assigns the uppercase of the parameter to suit. - A public setter method for symbol named SetSymbol() that assigns the uppercase of the parameter to symbol. - A public string constant method named ToString() that takes no parameters. It returns a string in the format [x:y], where x and y are the values of symbol and suit respectively. - A friend overloaded ostream operator that returns its output in the same format as ToString().

          In a header file named 'Card.h' within the namespace LB3, define a class named Card that must contain:
- A private char field named suit.
- A private char field named symbol.
- A public default constructor that assigns 'X' to both fields.
- A public copy constructor.
- A public assignment operator.
- A public empty destructor.
- A public constant getter method for suit named Suit().
- A public constant getter method for symbol named Symbol().
- A public setter method for suit named SetSuit() that assigns the uppercase of the parameter to suit.
- A public setter method for symbol named SetSymbol() that assigns the uppercase of the parameter to symbol.
- A public string constant method named ToString() that takes no parameters. It returns a string in the format [x:y], where x and y are the values of symbol and suit respectively.
- A friend overloaded ostream operator that returns its output in the same format as ToString().
        
Show more…

Added by Suzanne A.

Computer Science and Information Technology
Computer Science and Information Technology
Trishna Knowledge Systems 2018 Edition
AceChat toggle button
Close icon
Ace pointing down

Please give Ace some feedback

Your feedback will help us improve your experience

Thumb up icon Thumb down icon
Thanks for your feedback!
Profile picture
In a header file named 'Card.h' within the namespace LB3, define a class named Card that must contain: - A private char field named suit. - A private char field named symbol. - A public default constructor that assigns 'X' to both fields. - A public copy constructor. - A public assignment operator. - A public empty destructor. - A public constant getter method for suit named Suit(). - A public constant getter method for symbol named Symbol(). - A public setter method for suit named SetSuit() that assigns the uppercase of the parameter to suit. - A public setter method for symbol named SetSymbol() that assigns the uppercase of the parameter to symbol. - A public string constant method named ToString() that takes no parameters. It returns a string in the format [x:y], where x and y are the values of symbol and suit respectively. - A friend overloaded ostream operator that returns its output in the same format as ToString().
Close icon
Play audio
Feedback
Powered by NumerAI
Ivan Kochetkov David Collins
Danielle Fairburn verified

Willis James and 71 other subject AP CS educators are ready to help you.

Ask a new question

*

Labs

-

Want to see this concept in action?

NEW

Explore this concept interactively to see how it behaves as you change inputs.

View Labs

*

Key Concepts

-
Key Concept
Premium Feature
Explore the core concept behind this problem.
Play button
Key Concept
Premium Feature
Explore the core concept behind this problem.
Your browser does not support the video tag.

*

Recommended Videos

-
a-create-a-class-named-lease-with-fields-that-hold-an-apartment-tenants-name-apartment-number-monthly-rent-amount-and-term-of-the-lease-in-months-include-a-constructor-that-initializes-the-n-46522

a. Create a class named Lease with fields that hold an apartment tenant's name, apartment number, monthly rent amount, and term of the lease in months. Include a constructor that initializes the name to "XXX", the apartment number to 0, the rent to 1000, and the term to 12. Also include methods to get and set each of the fields. Include a non-static method named addPetFee() that adds $10 to the monthly rent value and calls a static method named explainPetPolicy() that explains the pet fee. Save the class as Lease.java. b. Create a class named TestLease whose main() method declares four Lease objects. Call a getData() method three times. Within the method, prompt a user for values for each field for a Lease, and return a Lease object to the main() method where it is assigned to one of main()'s Lease objects. Do not prompt the user for values for the fourth Lease object, but let it continue to hold the default values. Then, in main(), pass one of the Lease objects to a showValues() method that displays the data. Then call the addPetFee() method using the passed Lease object and confirm that the fee explanation statement is displayed. Next, call the showValues() method for the Lease object again and confirm that the pet fee has been added to the rent. Finally, call the showValues() method with each of the other three objects; confirm that two hold the values you supplied as input and one holds the constructor default values. Save the application as TestLease.java.

Willis J.

using-java-consider-a-superclass-purchaseitem-which-models-customers-purchases-this-class-has-two-private-instance-variables-name-string-and-unitprice-double-one-constructor-to-initialize-th-38345

Consider a superclass PurchaseItem which models a customer's purchases. This class has two private instance variables: name (String) and unitPrice (double). It also has one constructor to initialize the instance variables, and a default constructor to initialize name to "no item" and unitPrice to 0 using this(). Additionally, it has a method called getPrice that returns the unitPrice, as well as accessor and mutator methods. Lastly, there is a print method that returns the name of the item followed by the @ symbol and then the unitPrice. There are two subclasses of PurchaseItem: WeighedItem and CountedItem. WeighedItem has an additional instance variable called weight (double) in Kg, while CountedItem has an additional variable called quantity (int), both of which are private. For each of the subclasses, an appropriate constructor should be written that makes use of the constructor of the superclass to define the subclass constructors. The getPrice method should be overridden in each subclass to return the price of the purchased item based on its unit price and weight (for WeighedItem) or quantity (for CountedItem). The getPrice method of the superclass should be used in the subclass implementations. The toString method should also be overridden for each class, making use of the toString method of the superclass to define the subclass toString methods. The toString method should return something that can be printed on the receipt. For example: - For the WeighedItem class: "Banana @ 3.00 1.37Kg 4.11 SR" - For the CountedItem class: "Pens @ 4.5 10 units 45 SR" An application class should be written where objects are constructed from the two subclasses and printed on the screen.

Akash M.

c-you-are-to-create-a-class-object-called-employee-which-included-eight-private-variables-firstn-lastn-idnum-wage-holds-how-much-the-person-makes-per-hour-weekhrswkd-holds-how-many-total-hou-33627

You are to create a class object called "Employee" which includes eight private variables: - firstN - lastN - idNum - wage: holds how much the person makes per hour - weekHrsWkd: holds how many total hours the person worked each week. - regHrsAmt: initialize to a fixed amount of 40 using a constructor. - regPay - otPay After going over the regular hours, the employee gets 1.5x the wage for each additional hour worked. Methods: - constructor - properties - CalcPay(): Calculate the regular pay and overtime pay. Create an "EmployeeDemo" class. In the main function, the program should ask the user the number of employees in the company and create a 2-dimensional dynamic array (number of employees by 4 weeks). Then, the program should ask the user to enter each employee's information and the amount of hours they worked weekly. The program shows a menu with the employee's name for the user to choose which employee to display the following information: - How much the person totally made - How much of the paycheck is regular pay - How much of the paycheck is overtime pay

Supreeta N.


*

Recommended Textbooks

-
Computer Science and Information Technology

Computer Science and Information Technology

Trishna Knowledge Systems 2018 Edition
achievement 1,514 solutions
Introduction to Programming Using Python

Introduction to Programming Using Python

Y. Daniel Liang 1st Edition
achievement 1,192 solutions
Computer Science - An Overview

Computer Science - An Overview

Glenn Brookshear, Dennis Brylow 12th Edition
achievement 1,543 solutions

*

Transcript

-
00:04 Hello, welcome to this lesson.
00:06 In this lesson we would have the least class.
00:09 And now it's going to call the list class will contain four fields.
00:13 So we'll have the name.
00:17 We would have an integer which is the number and would have the double, which is then would have an integer, which is the term.
00:32 Okay.
00:33 So this would have the default constructor.
00:38 Now, this would have the default constructor.
00:39 The default constructor would have the name set to s x the number and amount in a 10 that we'd have the getters and setters for the four fields okay so we'll have the gettus and set set these are the gutters we have the name the number the amount in a time after that will have the status okay then the next one would have a stack a non -static method called the ad pet fee so probably void and now what we do is that it will take the amount and add ten dollars to it okay after that will call another static method so probably static void explain so the spline policy would simply print out the explain the policy simply say there is extra $10 bill for your okay so that is all that would have in here so this method will call the explain it policy.
02:58 Okay, now we'll create another class called the test, lease.
03:16 And now all that will do is to test the lease class.
03:24 So we have public, static boy, main, strength.
03:39 Just the main method so this would have the name show user a prompt so say when you say enter name so this obviously the name of the tenant we'll do the name equals to the scanner so scanner.
04:41 And now we'll capture the name into this so we do for the other four okay so here we do for the number for the amount and for the 10 that will set so say l.
05:03 Or set name then we do l dot set number we do l dot set amount then set 10.
05:38 Okay so after that we would return the the last one that we do is to do the show data so that is probably static void which is a lease object and now this we use the system it's your system but out of print to actually print the name the to print the name the number mount and a time so i'm going to use string the format to do this to string the format so here i need the name the name i need a i need a and i need that term okay so here i'll use the string templates to do this in these spaces so that becomes nicely formatted okay so when they're ax out of this i'll put l.
08:00 Let's get name, so get name, then elders get number, elders, get amount, then elud, get them.
08:33 So basically, that is all for the show data.
08:36 So now let's move into the main method...
Need help? Use Ace
Ace is your personal tutor. It breaks down any question with clear steps so you can learn.
Start Using Ace
Ace is your personal tutor for learning
Step-by-step explanations
Instant summaries
Summarize YouTube videos
Understand textbook images or PDFs
Study tools like quizzes and flashcards
Listen to your notes as a podcast
Continue solving this problem
Create a free account to:
  • View full step-by-step solution
  • Ask follow-up questions with Ace AI
  • Save progress and study later
Continue Free
Numerade

Get step-by-step video solution
from top educators

Continue with Clever
or



By creating an account, you agree to the Terms of Service and Privacy Policy
Already have an account? Log In

A free answer
just for you

Watch the video solution with this free unlock.

Numerade

Log in to watch this video
...and 100,000,000 more!


EMAIL

PASSWORD

OR
Continue with Clever