Lab13A: A Tale of Two Classes When teaching objects often you may hear the example "a chair is an object". Well for this lab, we are going to use this example. Create a class called "Chair", this is going to be a class which can create "Chair" objects. Also create a separate class to drive the function of Chair, call this driver class "Lab13A". The Driver class will contain the main method you typically make while Chair will not have a main method. Chair class: Variables (Attributes): - notice they are public. This isn't normal, but it's ok for this lab. o public int numOfLegs o public bool/boolean rolling o public String/string material //what is the chair made of //how many legs are on the chair //does it roll or not Using these attributes you can describe most chairs. For example, you might have a wooden chair with 4 legs that does not roll, or you may have a rolling chair made of leather with 5 legs. Now that you know the parameters and their data types you can make a constructor also called Chair; a constructor is a special method that shares its name with the class name, it is responsible for creating the object and starting it off with values for its attributes. It should take in user inputs to provide meaningful info for each attribute. This class isn't going to have any methods, so it should only include a constructor and the attributes. Driver class: This class is going to have a main method and take user input for the attributes for the Chair object. Once you have all that information, create a new object with those variables as parameters. Once you have done that, print out the information about your chair. You can use the name of your Chair object and the dot operator (a period) to print out info about the chair you created. Then, to show you really understand how the dot operator can work. Change the attributes to: numOfLegs = 4; rolling material = wood; = false; %3D Finally, repeat your print statement you wrote earlier to print out what the chair looks like.
Lab13A: A Tale of Two Classes When teaching objects often you may hear the example "a chair is an object". Well for this lab, we are going to use this example. Create a class called "Chair", this is going to be a class which can create "Chair" objects. Also create a separate class to drive the function of Chair, call this driver class "Lab13A". The Driver class will contain the main method you typically make while Chair will not have a main method. Chair class: Variables (Attributes): - notice they are public. This isn't normal, but it's ok for this lab. o public int numOfLegs o public bool/boolean rolling o public String/string material //what is the chair made of //how many legs are on the chair //does it roll or not Using these attributes you can describe most chairs. For example, you might have a wooden chair with 4 legs that does not roll, or you may have a rolling chair made of leather with 5 legs. Now that you know the parameters and their data types you can make a constructor also called Chair; a constructor is a special method that shares its name with the class name, it is responsible for creating the object and starting it off with values for its attributes. It should take in user inputs to provide meaningful info for each attribute. This class isn't going to have any methods, so it should only include a constructor and the attributes. Driver class: This class is going to have a main method and take user input for the attributes for the Chair object. Once you have all that information, create a new object with those variables as parameters. Once you have done that, print out the information about your chair. You can use the name of your Chair object and the dot operator (a period) to print out info about the chair you created. Then, to show you really understand how the dot operator can work. Change the attributes to: numOfLegs = 4; rolling material = wood; = false; %3D Finally, repeat your print statement you wrote earlier to print out what the chair looks like.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
langauge is c++
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images
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.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education