Microsoft Visual C#
7th Edition
ISBN: 9781337102100
Author: Joyce, Farrell.
Publisher: Cengage Learning,
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 9, Problem 8RQ
Assume that you have created a class named MyClass. The header of the MyClass constructor can be ____________.
- public MyClass()
- public MyClass (double d)
- Either of these can be the constructor header.
- Neither of these can be the constructor header.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Assignment 2
A Student class has the following attributes:
String name;
String streetAddress;
int age;
String phonNumber;
String mobileNumber;
Requirements:
. Create the setters and getters
. Create one default constructor
• create one paramertized constructor
• Create an object of the class using the default constructor
.
●
.
Create another object of the class using the paramertized constructor
Make sure to suply the values from the keyboard
Print the information about each employee
.
Make sure to add comments to you code and that your code is indented corectly
. Use the camelCase naming convension.
. Use try and catch block.
After you are doneo
a samle run and tak a screenshot of it.
zip the screenshot and the sourc code file and upload the zipped file to the Blackboard.
Write a class named Car that has the following data attributes:
_ _year_model (for the car’s year model)
_ _make (for the make of the car)
_ _speed (for the car’s current speed)
The Car class should have an _ _init_ _ method that accepts the car’s year model and make as
arguments. These values should be assigned to the object’s _ _year_model and _ _make data
attributes. It should also assign 0 to the _ _speed data attribute.
The class should also have the following methods:
accelerate - The accelerate method should add 5 to the speed data attribute each time it is called but not higher than 100.
brake - The brake method should subtract 5 from the speed data attribute each time it is called but not lower than 0.
get_speed - The get_speed method should return the current speed.
Next, design a program that creates a Car object then calls the accelerate method five times.
After each call to the accelerate method, get the current speed of the car and display it. Then
call the…
True or False
___(37) If class B is a child class of class A, when you create an object from class B, both the constructor of class B and the constructor from the class A are used to create the object.
___(38) An Interface can have a method that contains an empty method body.
___(39) An object can have another object as its private variable.
Chapter 9 Solutions
Microsoft Visual C#
Ch. 9 - Assume that you have created a class named...Ch. 9 - Prob. 9RQCh. 9 - Assume that you have created a class named...Ch. 9 - Create an application named SalesTransactionDemo...Ch. 9 - Create an application named CarDemo that declares...Ch. 9 - Create a program named SalesTaxDemo that declares...Ch. 9 - Prob. 8ECh. 9 - Write a program named DemoJobs for Harolds Home...Ch. 9 - a. Write a FractionDemo program that instantiates...Ch. 9 - Prob. 1DE
Knowledge Booster
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
- Using 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_forwardFor this program you need to create 3 classes: Ironman This class will be the base class The name of the Avenger. - property: name This is their number in the registry - property: badgenumber This is their height in meters - property: height Print the name of the Avenger, registry number, and their height - method print(): Constructor with no parameters should initialize name to Ironman, badgenumber to 6, and their height to 0.41 Thor Inherits from Ironman Constructor with no parameters should initialize name to Thor, badgenumber to 3, and his height to 2.1 Hulk Inherits from Thor Constructor with no parameters should initialize name to Hulk, badgenumber to 12, and his height to 4.7 For your program's Main: Create an Ironman, Thor, and Hulk Use the print function for each avenger. Output should be this: Ironman 6 0.41 Thor 3 2.1 Hulk 12 4.7arrow_forwardExercise 1-Account class • Design a class named Account that contains : • A private int data field named id for the account • A private double data field named balance for the account • A privet Date data field named dateCreated that stores the date when the account was created • A no-arg constructor that creates a default account • A constructor that creates an account with the specified id and initial balance • The getters (i.e., accessors) and setters (i.e., mutators) methods for id and balance • The getter method for dateCreated • A method named withdraw that withdraws a specified amount from the account • A method named deposit that deposits a specified amount to the accountarrow_forward
- The main advantage of the encapsulation is that, it provides abstraction between an object and its clients. Select one: O True OFalse Encapsulation is the process of grouping the attributes and method of an object together in a single data structure known as a class Select one: O True O False A constructor is a member variable that is called automatically when an object is created. Select one: O True O False We cannot declare more than one constructor per class. Select one: O True O False onarrow_forwardA. Car Class Create a Python Program where you write a class named Car that has the following data attributes: • _ _year_model (for the car's year model) • __make (for the make of the car) • _ _speed (for the car's current speed) The Car class should have an _init_ method that accepts the car's year model and make as arguments. These values should be assigned to the object's _year_model and make data attributes. It should also assign 0 to the __speed data attribute. The class should also have the following methods: accelerate() The accelerate method should add 5 to the speed data attribute each time it is called. brake() The brake method should subtract 5 from the speed data attribute each time it is called. • get_speed() The get_speed method should return the current speed. Next, design a program that creates a Car object then calls the accelerate method five times. After each call to the accelerate method, get the current speed of the car and display it. Then call the brake method…arrow_forwardJava please svalb mearrow_forward
- Homework Assignment Chapter 10b Create a new Java Project named Chap10b Create a class named Vehicle that acts as a superclass for vehicle types. The Vehicle class contains private data fields for the number of wheels and the average number of miles per gallon. The Vehicle class contains getters and setters for the data fields. The Vehicle class also contains a constructor receiving integer parameters for the number of wheels and average miles per gallons, and a display() method that prints the required output (use get methods). Create two subclasses, Car and MotorCycle, that each extend the Vehicle class. Each subclass contains a constructor that accepts the miles-per-gallon value as an argument and forces the number of wheels to the appropriate value-2 for a MotorCycle and 4 for a Car. Use the superclass constructor to set the wheels and mpg data fields (use the super keyword). Write a UseVehicle class to instantiate one object of each subclass and calls the display method to print…arrow_forwardWrite a class named Car that has the following member variables: yearModel: An int that holds the car’s year model. name: A string that holds the name of the car. company: A string that holds the company of the car. speed: An int that holds the car’s current speed. In addition, the class should have the following member functions. Mutator: Appropriate accessor functions to set the values of object’s yearModel, name, company, and speed member variables. Accessor: Appropriate accessor functions to get the values stored in an object’s yearModel, company, and speed member variables. Accelerate: The accelerate function should add 5 to the speed member variable each time it is called. Brake: The brake function should subtract 5 from the speed member variable each time it is called. Demonstrate the class in a program that creates a Car object, call the setter functions to set the values and then call the accelerate function five times. After each call to the accelerate function, get…arrow_forwardComputer Science Write the code to define a class called student. The student class should contain a data attribute called name and another attribute called gpa. Write the Student class to include an initializer method __init__ and a __str__ method. Create two different objects of the student class and call print on each object to display the output in the __str__method.arrow_forward
- Question 1Create a program that allows users to create a bank account. Users are to choose whichaccounts they want to create; either cheque or saving. To create an account, the user needs afull name and pin code. The pin code will be used before any operation is allowed.Bank_Account should be the base class and have two derived classes: Cheque_Account and Savings_account.Bank_Account should have the following methods as public:createAccount();checkBalance();withdraw();deposit();getAccountStatement();getPin();setAccountType ();getAccountType();Both withdraw and deposit should be virtual functions. All the account details – name, balance,and PIN CODE – should be stored in a struct.The program should have a menu that displays all the options for the user. ChequeAccount should have the following methods: withdraw(), getStatement(), writeCheques()viewAllCheques(). The cheque should be stored in a struct. A maximum of 10 cheques should beallowed. A cheque should have a name and amount.…arrow_forwardThis function is used to check whether an object is an instance of a specific class or a subclass of that class. a. isinstance b. isobject c. isreference d. _ _str_ _arrow_forwardNewspaperSubscriber class- create an abstract class named NewspaperSubscriber with attributes to contain the subscriber’s street address and the subscription rate. Include get and set methods for both these attributes. The set method for the rate is abstract. The setAddress method must prompt the user to enter the subscriber’s address through the use of a dialog box. Create a constructor for the base class. Create a toString() method that concaternates and returns the subscriber’s street address and rate for display. Create 3 child classes named SevenDaySubscriber, Weekday Subscriber, and Weekend Subscriber. Each child class has an additional attribute called subType, which is a String, that will store the type of newspaper subscription. Create a setType method that will set the type of subscriber as follows: “Seven Day”, “Weekday”, or“Weekend”. Create a setRate method for each child class that sets the rate as follows: a SevenDaysubscriber pays R18.00 per week for his newspapers, a…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,C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
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