Microsoft Visual C#
7th Edition
ISBN: 9781337102100
Author: Joyce, Farrell.
Publisher: Cengage Learning,
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
thumb_up100%
Chapter 10, Problem 2E
Program Plan Intro
Program Plan:
- Create a class Photo and include data member width and height of type double in it.
- Include property for each data member.
- Add protected field named price and set property for its get accessor.
- Create constructor of class to take two arguments for width and height and set the value of price field as per mentioned rules of height and width.
- Derive class MattedPhoto, add additional field color in it and override the base constructor to change the value of price field.
- Derive class FramedPhoto, add additional fields material and style and override the base constructor to change the value of price field.
- Create a program class having main method. Inside the main method create objects of each of above class and use ToString method to display the attributes of these classes.
Program Description:
The main purpose of the program is to create a class Photo, derive two other classes MattedPhoto and FramedPhoto from it and demonstrate method of these classes.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
Create an application named PhotoDemo that demonstrates the methods of three related classes for a company that develops photographs.Create a class named Photo that includes fields for width and height in centimeters and properties for each field. Include a protected price field, and set it to $3.99 for an 8-inch by 10-inch photo, $5.99 for a 10-inch by 12-inch photo, and $9.99 for any other size (because custom cutting is required). The price field requires a get accessor but no set accessor. Also include a ToString() method that returns a string constructed from the values of the fields. Derive two subclasses MattedPhoto and FramedPhoto. The MattedPhoto class includes a string field to hold a color, and the FramedPhoto class includes two string fields that hold the frame’s material (such as silver) and style (such as modern). The price for a MattedPhotoincreases by $10 over its base cost, and the price for a FramedPhoto increases by $25 over its base cost. Each subclass should…
Create an application named ShapesDemo that creates several objects that descend from an abstract class called GeometricFigure. Each GeometricFigure includes a height, a width, and an area.
Provide get and set accessors for each field except area; the area is computed and is read-only. Include an abstract method called ComputeArea() that computes the area of the GeometricFigure.
Next you will create three additional classes derived from the GeometricFigure class. Name these derived classes: Rectange, Square, and Triangle
Create a Rectangle is a GeometricFigure whose area is determined by multiplying width by height.
Create a Square is a Rectangle in which the width and height are the same. Provide a constructor that accepts both height and width, forcing them to be equal if they are not. Provide a second constructor that accepts just one dimension and uses it for both height and width. The Square class uses the Rectangle’s ComputeArea() method.
Create a Triangle is a GeometricFigure…
Create an application named ShapesDemo that creates several objects that descend from an abstract class called GeometricFigure. Each GeometricFigure includes a height, a width, and an area. Provide get and set accessors for each field except area; the area is computed and is read-only. Include an abstract method called ComputeArea() that computes the area of the GeometricFigure. Next you will create three additional classes derived from the GeometricFigure class. Name these derived classes: Rectange, Square, and Triangle.
Chapter 10 Solutions
Microsoft Visual C#
Ch. 10 - Create an application class named LetterDemo that...Ch. 10 - Prob. 2ECh. 10 - Create an application for Ninas Cookie Emporium...Ch. 10 - Prob. 5ECh. 10 - Prob. 7ECh. 10 - Create an application named TurningDemo that...Ch. 10 - Write a program named SalespersonDemo that...Ch. 10 - Each of the following files in the Chapter.10...Ch. 10 - In Chapter 9, you created a Contestant class for...
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
- Create an application class named LetterDemo that instantiates objects of two classes named Letter and CertifiedLetter and that demonstrates all their methods. The classes are used by a company to keep track of letters they mail to clients. The Letter class includes auto-implemented properties for the name of the recipient and the date mailed. Also, include a ToString() method that overrides the Object classs ToString() method and returns a string that contains the name of the class (using CetType and the Letters data field values. Create a child class named CertifiedLetter that includes an auto-implemented property that holds a tracking number for the letter.arrow_forwardYou are designing an application to rate your professors.a. Professors have the following properties: first name, last name, universityname, subject, and ratings for overall quality (1.0-5.0) and level of difficulty(1.0-5.0). Your class should have instance variables of the appropriatetype for each property.b. Your class should have two constructors: one that takes all properties, andone that takes only first name, last name, university name, and subjectand sets both of the ratings to an appropriate default value.c. You should provide accessors (getters) and mutators (setters) for firstname, last name, university name, and subject.d. Your class should provide a method to add a new rating for the professor.It should take two arguments: one for overall rating and one for level ofdifficulty, with values from 1 (awful) to 5 (awesome). Each time a newrating is provided, your class should calculate the average rating for theprofessor and update the appropriate variable for each.e. Your class…arrow_forwardCreate a method named getCircleDiameter that takes a radius of double type as the parameter. The method should return the diameter of a circle. To compute the diameter of a circle, multiply the radius by 2.Create a struct named Product where its fields are code, description, and price. Create a class named Person with an instance variable named full_name. Declare one (1) constructor without a parameter and initialize the variable with a default value.Create a class named Account with an instance variable named account_number. Make this class a member of the Accounts namespace.arrow_forward
- Create an application class named PhotoDemo that demonstrates the methods of three related classes for a company that develops photographs. Create a class named Photo that includes fields for width andheight in inches and properties for each field. The class should contain get and set accessors named Width and Height respectively. Include a protected price field, and set it to $3.99 for an 8-inch by 10-inch photo, $5.99 for a 10-inch by 12-inch photo, and $9.99 for any other size (because custom cutting is required). The price field requires a get accessor but no set accessor. Also include a ToString() method that returns a string constructed from the return value of the object’s GetType() method and the values of the fields. Derive two subclasses— MattedPhoto and FramedPhoto. The MattedPhoto class includes a string field named Color to hold a color, and the FramedPhoto class includes two string fields that hold the frame’s material (such as silver) and style (such as modern), named…arrow_forwardCreate an application class named PhotoDemo that demonstrates the methods of three related classes for a company that develops photographs. Create a class named Photo that includes fields for width andheight in inches and properties for each field. The class should contain get and set accessors named Width and Height respectively. Include a protected price field, and set it to $3.99 for an 8-inch by 10-inch photo, $5.99 for a 10-inch by 12-inch photo, and $9.99 for any other size (because custom cutting is required). The price field requires a get accessor but no set accessor. Also include a ToString() method that returns a string constructed from the return value of the object’s GetType() method and the values of the fields. Derive two subclasses— MattedPhoto and FramedPhoto. The MattedPhoto class includes a string field named Color to hold a color, and the FramedPhoto class includes two string fields that hold the frame’s material (such as silver) and style (such as modern), named…arrow_forwardCreate a Shape class that shall have color and filled instance variables of enum Color and boolean type. The filled boolean variable shall show, whether the shape is filled (colored). The enum Color shall be defined within the class having 4 color names (choose any four). Also define getArea and getPerimeter method in Shape class, both shall return 0. Create Rectangle class with length and width attributes and a Circle class with radius attribute, of type double. Properly encapsulate all fields. Circle and Rectangle shall extend Shape class and override getArea and getPerimters methods as per its type and specific formula. In Test class, create an object of Rectangle and Circle, by initializing all attributes in constructor and print both shapes' area and perimters. In Test class, define a static method with following signature, public static void printEachShapeCount(Shape... shapes) As you know, the parent type variable can hold the reference of any child class object. That…arrow_forward
- The Rectangle class) Following the example of the Circle class in Section 9.2, design a class named Rectangle to represent a rectangle. The class contains: ■ Two double data fields named width and height that specify the width and height of the rectangle. The default values are 1 for both width and height. ■ A no-arg constructor that creates a default rectangle. ■ A constructor that creates a rectangle with the specified width and height. ■ A method named getArea() that returns the area of this rectangle. ■ A method named getPerimeter() that returns the perimeter.Draw the UML diagram for the class and then implement the class. Write a test program that creates two Rectangle objects—one with width 4 and height 40and the other with width 3.5 and height 35.9. Display the width, height, area, and perimeter of each rectangle in this order.arrow_forwardYou are required to create a program that simulates an ATM with below requirements:Create a class called Account that contains:• An int data field named id that stores the accounts unique identification number.• A double data field named balance that stores the current balance of the account.• A Date data field named dateCreated that stores the date on which the account was created.• A constructor that creates an account with the specified id and initial balance.• Methods that return the values of all data fields.• Methods that set the values of the id and balance data fields.• A method named withdraw that withdraws a specified amount from the Account.• A method named deposit that deposits a specified amount into the account.• A method named printStatement that print the user statement. Option 1:Check Balance: This will allow the user to view the current balance. Use JOptionPane to display the balance from the data base. Option 2:Withdraw: This will provide another window (Do not use…arrow_forwardYou are required to create a program that simulates an ATM with below requirements:Create a class called Account that contains:• An int data field named id that stores the accounts unique identification number.• A double data field named balance that stores the current balance of the account.• A Date data field named dateCreated that stores the date on which the account was created.• A constructor that creates an account with the specified id and initial balance.• Methods that return the values of all data fields.• Methods that set the values of the id and balance data fields.• A method named withdraw that withdraws a specified amount from the Account.• A method named deposit that deposits a specified amount into the account.• A method named printStatement that print the user statement. Option 1:Check Balance: This will allow the user to view the current balance. Use JOptionPane to display the balance from the data base. Option 2:Withdraw: This will provide another window (Do not use…arrow_forward
- Create a class called FinalGrade that is used to represent the points obtained in the letter grade of CSC 110 by different students. The FinalGrade class should include three pieces of information as instance variables—studentName (type String), studentID (type String), and pointsObtained (type int). Your class should have a constructor that initializes the three instance variables. Provide a set and a get method for each and every instance variable. In addition, provide a method named computeLetterGrade that returns the letter grade obtained by the student taking the pointsObtained as an argument. For the grading policy refer to CSC 110 grading scheme specified in syllabus. Write a test application named FinalGradeDriver that creates at least 3 different objects of class FinalGrade and test all the methods of class FinalGrade. Sample Output Student Name : Homer SimpsonStudent ID : S123456Points Obtained : 99Letter Grade : A Student Name : Marge SimpsonStudent ID : S234567Points…arrow_forwardCreate 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…arrow_forwardFollowing the example of the Circle class in Section 9.2 , design a class named Stock that contains: A string data field named symbol for the stock’s symbol. A string data field named name for the stock’s name. A double data field named previousClosingPrice that stores the stock price for the previous day. A double data field named currentPrice that stores the stock price for the current time. A constructor that creates a stock with the specified symbol and name. A method named getChangePercent() that returns the percentage changed from previousClosingPrice to currentPrice. Write a test program that creates a Stock object with the stock symbol ORCL, the name Oracle Corporation, and the previous closing price of 34.5. Set a new current price to 34.35. Select 9 more stocks with the current prices and create objects with the current prices as previous Closing prices. After 2 or more days get the price for each stock in your list and use the currentPrice method to store the current…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 - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
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
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT