{40 points} Write a program using proper Object Oriented Programming (including good encapsulation) for a Student class. Work from the starter code provided. Your code should extend and complete the TO DO items in the file (you need to finish the implementation of both the OOP class methods and the test code in main). See details in the starter code. Student class will Store data or attribute values for a student's name, age, and current residence hall • Allow variables of type Student to be created (these are objects) Provide a way for a student object to change its residence hall Compare two students and decide if they are in the same residence hall • Allow some or all of the information on a student to be printed out when requested Work from the starter code Student java provided. Main is provided in the starter code but extensions are necessary. For the TO DOs, add pseudo code for the additions you make. Ensure you follow proper OOP programming and style requirements as we have learned in class. BE SURE TO SHOW ADEQUATE PSEUDO CODE to explain your work and show that you did THINK BEFORE PROGRAMMING.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter10: Classes And Data Abstraction
Section: Chapter Questions
Problem 6SA
icon
Related questions
Question

Fill out the starter code 

QUESTION 2: PROGRAMMING WITH OOP
{40 points} Write a program using proper Object Oriented Programming (including good
encapsulation) for a Student class. Work from the starter code provided. Your code should extend
and complete the TO DO items in the file (you need to finish the implementation of both the OOP
class methods and the test code in main).
See details in the starter code. Student class will
Store data or attribute values for a student's name, age, and current residence hall
Allow variables of type Student to be created (these are objects)
Provide a way for a student object to change its residence hall
Compare two students and decide if they are in the same residence hall
Allow some or all of the information on a student to be printed out when requested
Work from the starter code Student.java provided. Main is provided in the starter code but
extensions are necessary. For the TO DOS, add pseudo code for the additions you make.
Ensure you follow proper OOP programming and style requirements as we have learned in
class.
BE SURE TO SHOW ADEQUATE PSEUDO CODE to explain your work and show that
you did THINK BEFORE PROGRAMMING.
Transcribed Image Text:QUESTION 2: PROGRAMMING WITH OOP {40 points} Write a program using proper Object Oriented Programming (including good encapsulation) for a Student class. Work from the starter code provided. Your code should extend and complete the TO DO items in the file (you need to finish the implementation of both the OOP class methods and the test code in main). See details in the starter code. Student class will Store data or attribute values for a student's name, age, and current residence hall Allow variables of type Student to be created (these are objects) Provide a way for a student object to change its residence hall Compare two students and decide if they are in the same residence hall Allow some or all of the information on a student to be printed out when requested Work from the starter code Student.java provided. Main is provided in the starter code but extensions are necessary. For the TO DOS, add pseudo code for the additions you make. Ensure you follow proper OOP programming and style requirements as we have learned in class. BE SURE TO SHOW ADEQUATE PSEUDO CODE to explain your work and show that you did THINK BEFORE PROGRAMMING.
public class Student {
/*
Starter code for your Student class and tests from main
See the TO DO comments for hints on how to proceed
Be sure your code compiles and runs when finished!
*/
private String name;
private int age;
private String residenceHall;
//constructor
public Student (String n, int a, String dorm) {
name = n;
age = a;
residenceHall = dorm;
}
/*
TO DOs to finish the Student class
Using good encapsulation, provide code that will allow you to extend the code in main (see those TO DOs
Consider:
TO DO 1: provide a mutator method that updates a Student's residenceHall
TO DO 2: provide some mechanism (several are possible) so that main can compare residenceHalls for two Students
TO DO 3: ensure main can print out Student's names after checking for matching residences (some kind of accessor method)
*/
//test code in main
public static void main(String[] args){
Student richard;
Student jane;
Student sue;
richard = new Student("Richard Smith",19,"San Francisco Hall");
jane = new Student ("Jane Dold", 21, "Fairfield Hall");
sue = new Student("Sue Alexander", 20, "Georgetown Hall");
/*TO DO 1: check to see if Richard and Sue are in the same residence hall;
if so, print out their names and say they are both in same dorm building; otherwise, do nothing
TO DO 2: change Sue's residence hall to Fairfield Hall
TO DO 3: check to see if Jane and Sue are in the same residence hall;
if so, print out their names and say they are both in same dorm building; otherwise, do nothing
YOUR CODE CANNOT RELY ON KNOWING THE VALUES FOR CURRENT RESIDENT HALL ASSIGNMENTS
USE PROPER OOP TO GET THESE VALUES
*/
}
Transcribed Image Text:public class Student { /* Starter code for your Student class and tests from main See the TO DO comments for hints on how to proceed Be sure your code compiles and runs when finished! */ private String name; private int age; private String residenceHall; //constructor public Student (String n, int a, String dorm) { name = n; age = a; residenceHall = dorm; } /* TO DOs to finish the Student class Using good encapsulation, provide code that will allow you to extend the code in main (see those TO DOs Consider: TO DO 1: provide a mutator method that updates a Student's residenceHall TO DO 2: provide some mechanism (several are possible) so that main can compare residenceHalls for two Students TO DO 3: ensure main can print out Student's names after checking for matching residences (some kind of accessor method) */ //test code in main public static void main(String[] args){ Student richard; Student jane; Student sue; richard = new Student("Richard Smith",19,"San Francisco Hall"); jane = new Student ("Jane Dold", 21, "Fairfield Hall"); sue = new Student("Sue Alexander", 20, "Georgetown Hall"); /*TO DO 1: check to see if Richard and Sue are in the same residence hall; if so, print out their names and say they are both in same dorm building; otherwise, do nothing TO DO 2: change Sue's residence hall to Fairfield Hall TO DO 3: check to see if Jane and Sue are in the same residence hall; if so, print out their names and say they are both in same dorm building; otherwise, do nothing YOUR CODE CANNOT RELY ON KNOWING THE VALUES FOR CURRENT RESIDENT HALL ASSIGNMENTS USE PROPER OOP TO GET THESE VALUES */ }
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Data members
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage