You are on page 1of 11

YELAHANKA, BENGALURU-560064

LA-2
Submitted as a component of LA 2 for the subject of

OBJECT ORIENTED MODELING AND DESIGN

IN

INFORMATION SCIENCE AND ENGINEERING

BY

Mansij Gupta - 1NT18IS089

INFORMATION SCIENCE AND ENGINEERING NMIT, BENGALURU

1 | Page
1. Question - Student Registration flow MVC

● STRUCTURE

2 | Page
● CLASS DIAGRAM

3 | Page
● MODEL - Student.java

public class Student {

private String rollNo;

private String name;

private String class;

private String section;

public String getRollNo() {

return rollNo;

public void setRollNo(String rollNo) {

this.rollNo = rollNo;

public String getName() {

return name;

public void setName(String name) {

this.name = name;

public String getClass() {

return class;

4 | Page
}

public void setClass(String class) {

this.class = class;

public String getSection() {

return section;

public void setSection(String section) {

this.section = section;

5 | Page
● VIEW - StudentView.java

public class StudentView {

public void printStudentDetails(String studentName, String


studentRollNo, String studentClass, String studentSection){
System.out.println("New Student: ");

System.out.println("Name: " + studentName);

System.out.println("Roll No: " + studentRollNo);

System.out.println("Class: " + studentClass);

System.out.println("Section: " + studentSection);

6 | Page
● CONTROLLER - StudentController.java

public class StudentController {

private Student model;

private StudentView view;

public StudentController(Student model, StudentView

view){ this.model = model;

this.view = view;

public void setStudentName(String

name){ model.setName(name);

public String getStudentName(){

return model.getName();

public void setStudentRollNo(String

rollNo){ model.setRollNo(rollNo);

public String getStudentRollNo(){

return model.getRollNo();

7 | Page
public void setStudentClass(String

class){ model.setClass(class);

public String getStudentClass(){

return model.getClass();

public void setStudentSection(String

section){ model.setSection(section);

public String getStudentSection(){

return model.getSection();

public void updateView(){

view.printStudentDetails(model.getName(),
model.getRollNo(), model.getClass(), model.getSection());
}

8 | Page
● MVC Design Pattern - MVCpattern.java

public class MVCpattern {

public static void main(String[] args) {

Student model =addNewStudent();

StudentView view = new StudentView();

StudentController controller = new StudentController(model,

view); Scanner sc= new Scanner(System.in);

System.out.print("Enter Student Name : "); String name =

sc.nextLine();

controller.setStudentName(name);

System.out.print("Enter Student Roll No : ");

String rollNo = sc.nextLine();

controller.setStudentRollNo(rollNo);

System.out.print("Enter Student Class :

"); String class = sc.nextLine();

controller.setStudentClass(class);

System.out.print("Enter Student Section :

"); String section = sc.nextLine();

controller.setStudentSection(section);

9 | Page
controller.updateView();

private static Student addNewStudent(){

Student student = new Student();

student.setName("");

student.setRollNo("");

student.setClass("");

student.setSection("");

return student;

10 | Page
● OUTPUT :-

Enter Student Name: Mansij

Enter Student RollNo: 89

Enter Student Class: 7

Enter Student Section: B

New Student:

Name: Mansij

Roll No: 89

Class: 7

Section: B

11 | Page

You might also like