Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I wasn't sure if I was doing this right and wanted to know if I could get the code with comments explaining each instance? I'll

I wasn't sure if I was doing this right and wanted to know if I could get the code with comments explaining each instance?
I'll post the entire lab but page 1 and 2 are thoroughly explained.
I also was not sure how to explain my answers in the questions.
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Lab 08 Summary: In this lab, you will design a series of four classes using both inheritance and composition. You will make a Driver, but we will not be filling it in this lab! We will use this lab as a foundation for lab 09, where we will actually fill out the driver and use all the classes we make in this lab. 1 SETTING UP THE PROJECT First, we need to set up our project. This will be a touch different than usual! Until now, we've been using the default package. This time, we will make our own package. 1. Make a new Java Project as usual and call it Lab_08_last_First 2. Once the project has been made make a new class called Driver a. In the "Package" textbox, put com.firstlast.lab_08 1. For example, mine would be com.bladefrisch.lab_08 New Java Class Java Class Create a new dava class Source folder Package Enclosing type Lab_08/ com.bladefrisch lab_08 Name Modifier Driver public Opackage abstract final java.lang. Object pre stati protected Supercles Interfaces: Which method stubs would you like to create public static void main(String[] argal Constructors from superclass inherited abstract methods Do you want to add comments? (Configure templates and default value het Generate comments Finish Cancel b. 3. After making the Driver class, we need to make a view adjustment to Eclipse a. Click on the three dots in the "Package Explorer" panel and select Package Presentation -> Hierarchical 1 Package Explorer Lab 01 Solution Lab_02_Solution Lab_03A_Solution Lab_038_Solution > Lab04_5olution Lab_05 Solution > Lab 06 Solution > Lab_07_Solution Lab 08 > System Library 10.11 sre com.bladetrinchi bon > Driver.java > tab_06_Solution Driverjava 1 package com.bladefrisch.lab Top Level Clements Select Working Set ver { Deselect Working Set Edit Active Working Set c void main 1 Window Working Set Auto-generat Package Presentation Show Reference Libraries Mode Link with Ester Hinwchical b. 2 PERSON CLASS Next, we will make a new package and begin filling it with our custom classes. The first one we make will be our base class. 1. Make a new class and call it Person a. When making it, add.data to the end of the package and make sure "public static void main(String[] args)" is unchecked New Have Class Java Class Ciestee lava chest. Browse Source folder Package Indong com. Bladevitch lab Name Medien Person public Opackage burat in Superclass Interfaces Adit Which method Stube would you like to creste! public static void main(Strings Construction from superless inherited methods Do you want to add comments Configure templates and default value Genette comments 2 Cancel b. 2. Make two instance variables: a first name and a last name a. These should be marked as protected 3. Make a default and overloaded constructor a. The default constructor should initialize the variables to the empty string b. Make only one overloaded constructor that accepts parameters for all instance variables 4. Make only getters for the first and last name 3 TEACHER CLASS Next, we will make a class to represent a teacher. 1. Make a new class and call it Teacher a. Again, make sure to add data to the end of the package if it is not there 2. Add "extends Person" after the dass name to get public class Teacher extends Person" 3. Make two instance String variables: title and subject a. These should be private 4. Make a default and overloaded constructor a. The default constructor should initialize all variables to the empty string i. This includes those inherited from Person! b. Make only one overloaded constructor that accepts parameters for all instance variables 5. Make only getters for the first name, last name, and subject 6. Make another method call getName() that returns the teacher's full name, including title a. For example, mine would be "Prof. Blade Frisch b. You can use String.format or StringBuilder to do this easily 7. What is the relationship (object design philosophy) between Teacher and Person? 4 STUDENT CLASS Next, we will make a class to represent a student 1. Make a new class and call it Student a. Again, make sure to add data to the end of the package if it is not there 2. Add "extends Person" after the dass name to get public class Student extends Person" 3. Make three instance variables: an int for id, a double for spa, and an ArrayList of Classes called transcript a. We will make the Class class last, so there will be an error with the ArrayList until we make it 1. ArrayList transcript; b. These should all be private = 4. Make a default and overloaded constructor a. The default should initialize all variables to reasonable default values for all instance variables i. This includes those inherited form Person! ii. For the ArrayList a reasonable default is to make the object b. The overloaded constructor should accept a first name, a last name, and an id i. Set the gpa and transcript to reasonable default values 1. Again, for the ArrayList this would be to create the object c. Make getters only for id, gpa, and transcript i. The return type for getTranscript () will be ArrayList 5. What is the relationship (object design philosophy) between Student and Person? 6. What is the relationship (object design philosophy) between Student and Class? a. 5 CLASS CLASS Finally, we will make our Class class, which will represent a single class that a student will take. 1. Make a class and call it Class a. Again, make sure to add .data to the end of the package if it is not there 2. Make three instance variables: a String to represent the name, an int to represent the grade received, and a Teacher to represent the teacher of the class a. These should all be private 3. Make five static final int variables to represent the grades A, B, C, D, and Fassigned the values 4, 3, 2, 1, and 0, respectively 4. Make a default and overloaded constructor a. The default should initialize all variables to reasonable default values 1. For Teacher, a reasonable default would be to create a default Teacher object b. The overloaded constructor should accept parameter for all the instance variables 5. Make getters only for name, grade, and teacher a. For grade, make two getters: getGradeCode () and getGrade Letter () i. getGradeCode() should return the int value of the grade ii. getGrade letter() should return a String representation of the grade 1. Use an if/else/if chain and the constants made is step 3 to determine which String to return 6. What is the relationship (object design philosophy) between Class and Teacher

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Second International Conference Acids Hue City Vietnam March 2010 Proceedings Part 1 Lnai 5990

Authors: Manh Thanh Le ,Jerzy Swiatek ,Ngoc Thanh Nguyen

2010th Edition

3642121446, 978-3642121449

More Books

Students also viewed these Databases questions

Question

Briefly describe the two methods for adjusting for unequal lives.

Answered: 1 week ago