Starting out with Visual C# (4th Edition)
4th Edition
ISBN: 9780134382609
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 9, Problem 2MC
Program Description Answer
Class declaration has to be written to create a class.
Hence, the correct answer is option “B”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
class SavingsAccount(object):
"""This class represents a savings account
with the owner's name, PIN, and balance."""
RATE = 0.02
def __init__(self, name, pin, balance = 0.0):
self._name = name
self._pin = pin
self._balance = balance
def __str__(self):
result = 'Name: ' + self._name + '\n'
result += 'PIN: ' + self._pin + '\n'
result += 'Balance: ' + str(self._balance)
return result
def getBalance(self):
return self._balance
def getName(self):
return self._name
def getPin(self):
return self._pin
def deposit(self, amount):
"""Deposits the given amount."""
self._balance += amount
return self._balance
def withdraw(self, amount):
"""Withdraws the given amount.
Returns None if successful, or an
error message if unsuccessful."""
if amount < 0:
return 'Amount must be >=…
Python program for this project:
Patient Charges
Write a class named Patient that has attributes for the following data:
First name, middle name, and last name
Address, city, state, and ZIP code
Phone number
Name and phone number of emergency contact
The Patient class’s _ _init_ _ method should accept an argument for each attribute. The Patient class should also have accessor and mutator methods for each attribute.
Next, write a class named Procedure that represents a medical procedure that has been performed on a patient. The Procedure class should have attributes for the following data:
Name of the procedure
Date of the procedure
Name of the practitioner who performed the procedure
Charges for the procedure
The Procedure class’s _ _init_ _ method should accept an argument for each attribute. The Procedure class should also have accessor and mutator methods for each attribute.
Next, write a program that creates an instance of the Patient class, initialized with sample data.
Then,…
Summary
In this lab, you create a derived class from a base class, and then use the derived class in a Python program. The program should create two Motorcycle objects, and then set the Motorcycle’s speed, accelerate the Motorcycle object, and check its sidecar status.
Instructions
Open the file named Motorcycle.py.
Create the Motorcycle class by deriving it from the Vehicle class. Call the parent class __init()__ method inside the Motorcycle class's __init()__ method.
In theMotorcycle class, create an attribute named sidecar.
Write a public set method to set the value for sidecar.
Write a public get method to retrieve the value of sidecar.
Write a public accelerate method. This method overrides the accelerate method inherited from the Vehicle class. Change the message in the accelerate method so the following is displayed when the Motorcycle tries to accelerate beyond its maximum speed: "This motorcycle cannot go that fast".
Open the file named MyMotorcycleClassProgram.py.
In the…
Chapter 9 Solutions
Starting out with Visual C# (4th Edition)
Ch. 9.1 - How is a class like a blueprint?Ch. 9.1 - Briefly describe the process of writing a class...Ch. 9.1 - What is a constructor?Ch. 9.1 - Prob. 9.4CPCh. 9.1 - When you pass an object that is an instance of a...Ch. 9.2 - What is a property?Ch. 9.2 - Prob. 9.7CPCh. 9.2 - Prob. 9.8CPCh. 9.2 - Prob. 9.9CPCh. 9.2 - Prob. 9.10CP
Ch. 9.3 - What is a parameterized constructor?Ch. 9.3 - Prob. 9.12CPCh. 9.3 - Prob. 9.13CPCh. 9.3 - What happens if you write a class with no...Ch. 9.3 - Describe the purpose of the default constructor.Ch. 9.4 - Prob. 9.16CPCh. 9.4 - How can you initialize an array of a class type...Ch. 9.4 - Prob. 9.18CPCh. 9.5 - Prob. 9.19CPCh. 9.5 - When designing an object-oriented application, who...Ch. 9.5 - How do you identify the potential classes in a...Ch. 9.5 - What are a classs responsibilities?Ch. 9.5 - What two questions should you ask to determine a...Ch. 9.5 - Will all a class's actions always be directly...Ch. 9.6 - Prob. 9.25CPCh. 9.6 - Prob. 9.26CPCh. 9.6 - Prob. 9.27CPCh. 9.6 - Prob. 9.28CPCh. 9.6 - Prob. 9.29CPCh. 9 - Each object that is created from a class is called...Ch. 9 - Prob. 2MCCh. 9 - The first line of a class declaration is known as...Ch. 9 - The classs________ are the statements that define...Ch. 9 - A(n) _____ is a method that is automatically...Ch. 9 - A(n) is a special type of class member that allows...Ch. 9 - A special set of methods, known as_________, work...Ch. 9 - Prob. 8MCCh. 9 - The parameter of the set accessor is automatically...Ch. 9 - A can be read, but it cannot be modified. a....Ch. 9 - When the value of an item is dependent on other...Ch. 9 - A constructor that accepts arguments is known as...Ch. 9 - Prob. 13MCCh. 9 - Prob. 14MCCh. 9 - A methods ______ consists of the methods name and...Ch. 9 - A is a constructor that accepts no arguments. a....Ch. 9 - If you write a class with no constructor...Ch. 9 - Prob. 18MCCh. 9 - A classs responsibilities are_______. a. the...Ch. 9 - Prob. 20MCCh. 9 - Objects that are instances of a class are always...Ch. 9 - Prob. 2TFCh. 9 - A class is an object.Ch. 9 - It is a common practice to make all a classs...Ch. 9 - The same rules for naming variables apply to...Ch. 9 - If you need to make a property read only, you...Ch. 9 - If you try to pass a property to a ref or an out...Ch. 9 - Class fields are almost always declared public in...Ch. 9 - The get accessor can be thought of as a method...Ch. 9 - Constructors can accept arguments in the same way...Ch. 9 - It is legal to write a class without any...Ch. 9 - Objects that are instances of a class can be...Ch. 9 - Prob. 13TFCh. 9 - One way to find the classes needed for an...Ch. 9 - Prob. 15TFCh. 9 - By default, a controls Modifiers property is set...Ch. 9 - Prob. 1SACh. 9 - What are the advantages of storing classes in...Ch. 9 - How is a constructor used?Ch. 9 - What is the difference between a class and an...Ch. 9 - What convention do most programmers follow when...Ch. 9 - What is the value parameter? How is it created?Ch. 9 - What is executed any time a class property is...Ch. 9 - What is executed any rime a value is assigned to a...Ch. 9 - How can you protect class fields from accidental...Ch. 9 - Prob. 10SACh. 9 - Is it possible to pass initialization values to...Ch. 9 - How does the compiler distinguish a method from...Ch. 9 - What do you call the constructor that is provided...Ch. 9 - Prob. 14SACh. 9 - Prob. 15SACh. 9 - Prob. 16SACh. 9 - Prob. 17SACh. 9 - Write a statement that creates an instance of the...Ch. 9 - Write the accessors for a property named...Ch. 9 - Prob. 3AWCh. 9 - Look at the following description of a problem...Ch. 9 - Pet Class Create a class named Pet (similar to the...Ch. 9 - Car Class Create a class named Car that has the...Ch. 9 - Personal Information Class Create a class that...Ch. 9 - Employee Class Write a class named Employee that...Ch. 9 - RetailItem Class Write a class named RetailItem...Ch. 9 - Dorm and Meal Plan Calculator A university has the...Ch. 9 - E-Mail Address Book Create an application with a...
Knowledge Booster
Similar questions
- The __________ declares that a derived class is allowed to override a method. a. void keyword b. protected keyword c. base keyword d. virtual keywordarrow_forwardsolve in python Street ClassStep 1:• Create a class to store information about a street:• Instance variables should include:• the street name• the length of the street (in km)• the number of cars that travel the street per day• the condition of the street (“poor”, “fair”, or “good”).• Write a constructor (__init__), that takes four arguments corresponding tothe instance variables and creates one Street instance. Street ClassStep 2:• Add additional methods:• __str__• Should return a string with the Street information neatly-formatted, as in:Elm is 4.10 km long, sees 3000 cars per day, and is in poor condition.• compare:• This method should compare one Street to another, with the Street the method is calledon being compared to a second Street passed to a parameter.• Return True or False, indicating whether the first street needs repairs more urgently thanthe second.• Streets in “poor” condition need repairs more urgently than streets in “fair” condition, whichneed repairs more…arrow_forwardjava When we create an object of a class, the object's instance variables are automatically initialized with its default values without us writing code in any constructor. Choose one of the options:TrueFalsearrow_forward
- #this is a python program #topic: OOP Design a class called Pokemon using a parameterized constructor so that after executing the following line of code the desired result shown in the output box will be printed. First object along with print has been done for you, you also need to create other objects and print accordingly to get the output correctly. [You are not allowed to change the code below] #Write your code for class here team_pika = Pokemon('pikachu', 'charmander', 90, 60, 10) print('=======Team 1=======') print('Pokemon 1:',team_pika.pokemon1_name, team_pika.pokemon1_power) print('Pokemon 2:',team_pika.pokemon2_name, team_pika.pokemon2_power) pika_combined_power = (team_pika.pokemon1_power + team_pika.pokemon2_power) * team_pika.damage_rate print('Combined Power:', pika_combined_power) #Write your code for subtask 2,3,4 here Output: =======Team 1======= Pokemon 1: pikachu 90 Pokemon 2: charmander 60 Combined Power: 1500 =======Team 2======= Pokemon 1:…arrow_forwardIn previous chapters, you have created programs for the Greenville Idol competition. Now create a Contestant class with the following characteristics: The Contestant class contains public static arrays that hold talent codes and descriptions. Recall that the talent categories are Singing Dancing, Musical instrument, and Other. The class contains an auto-implemented property that holds a contestants name. The class contains fields for a talent code and description. The set accessor for the code assigns a code only if it is valid. Otherwise, it assigns I for Invalid. The talent description is a read-only property that is assigned a value when the code is set. Modify the GreenvilleRevenue program so that it uses the Contestant class and performs the following tasks: The program prompts the user for the number of contestants in this years competition; the number must be between 0 and 30. The program continues to prompt the user until a valid value is entered. The expected revenue is calculated and displayed. The revenue is $25 per contestant. The program prompts the user for names and talent codes for each contestant entered. Along with the prompt for a talent code, display a list of the valid categories. After data entry is complete, the program displays the valid talent categories and then continuously prompts the user for talent codes and displays the names of all contestants in the category. Appropriate messages are displayed if the entered code is not a character or a valid code.arrow_forwardUsing classes, design an online address book to keep track of the names, addresses, phone numbers, and dates of birth of family members, close friends, and certain business associates. Your program should be able to handle a maximum of 500 entries. Define a class addressType that can store a street address, city, state, and ZIP code. Use the appropriate functions to print and store the address. Also, use constructors to automatically initialize the member variables. Define a class extPersonType using the class personType (as defined in Example 10-10, Chapter 10), the class dateType (as designed in this chapters Programming Exercise 2), and the class addressType. Add a member variable to this class to classify the person as a family member, friend, or business associate. Also, add a member variable to store the phone number. Add (or override) the functions to print and store the appropriate information. Use constructors to automatically initialize the member variables. Define the class addressBookType using the previously defined classes. An object of the type addressBookType should be able to process a maximum of 500 entries. The program should perform the following operations: Load the data into the address book from a disk. Sort the address book by last name. Search for a person by last name. Print the address, phone number, and date of birth (if it exists) of a given person. Print the names of the people whose birthdays are in a given month. Print the names of all the people between two last names. Depending on the users request, print the names of all family members, friends, or business associates.arrow_forward
- Could you please help me with this chapter 6 number 15 Programming challenge from Starting out with Java Gaddis 7th edition book. Thank youarrow_forwardinheritance in javaarrow_forwardWhat method is automatically executed whenever a new instance of the class, which the method belongs to, has been instantiated? a. encapsulation b. abstraction c. polymorphismarrow_forward
- Pyhton Code: Create a Pizza class which stores information about a single pizza. It contains the following: -Instance variables to store the size of the pizza (small, medium or large), (1)the number of cheese toppings, (2)the number of pepperoni toppings, and the (3) number of mushroom toppings. - Constructor: that takes four arguments and sets all of the corresponding instance variables and that initializes all instance variables to the zero of their type. - Methods to get (accessor) and set (mutator) each instance variable individually. - A method called calcCost() that returns the cost of the pizza. Pizza cost is determined by: Small: $10 + $2 per topping Medium: $12 + $2 per topping Large: $14 + $2 per topping. -A method which returns a string for the pizza size, quantity of each topping, and the pizza cost as calculated by the following example, a large pizza with 1 cheese, 2 pepperoni and 1 mushroom toppings should cost $22 (you can overwrite __str__).arrow_forwardAssignment: 1- Create a class called Book with the following attributes: 1. title: The title of the book. 2. author: The author of the book. 3. pages: The number of pages in the book. Use a constructor (__init___) to initialize these attributes when creating an object from the class. Add a method inside the class calle description() which returns a description of the book Lec 3: Classes and Objects Object-oriented programming 2- Create a class called Phone with the following attributes: 1. brand: The brand of the phone. 2. price: The price of the phone. Use a constructor (__init__) to initialize these attributes when creating an object from the class. Add a method inside the class called show_info(), which prints the phone's detailsarrow_forwardPlease code in python Create a program with two classes – the person class and the student The person class has the following properties: first name (first_name), last name (last_name) street address (address) city (city) zip code (zip) The class has the following methods: get_full_name, which returns the full name of a person get_full_address, which return greeting, returns a greeting message. The class should provide accessor and mutator for each property The class should override the __str__ method to return the state of the object. Create a child class called student which has a property named graduation year (graduation_year) and major. Provide accessor and mutator for each property of its own It inherits all the properties and methods of the person parent class as well. Create a test program that Create an object of the person class and print the full name of a person. Create an object of the person class and print…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning