Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA JAVA JAVA JAVA NEED HELPP - Make all ids auto generated, like incremental every object created. - Create toJson, fromJson methods for every model.

JAVA JAVA JAVA JAVA NEED HELPP - Make all ids auto generated, like incremental every object created. - Create toJson, fromJson methods for every model. **************************************

package school.model;

import java.util.*;

public class Student extends Person {

private SClass sClass; private List studentsMarks = new ArrayList<>(); Map studentMarks = new HashMap<>();

public Student(int id, String name, Date dateOfBirth, Gender gender, SClass sClass) { super(id, name, dateOfBirth, gender); this.sClass = sClass; }

public Student(int id, String name, Date dateOfBirth, Gender gender, List studentsMarks, Map studentMarks) { super(id, name, dateOfBirth, gender); this.studentsMarks = studentsMarks; this.studentMarks = studentMarks; }

public Student(int id, String name, Date dateOfBirth, Gender gender, List studentsMarks) { super(id, name, dateOfBirth, gender); this.studentsMarks = studentsMarks; }

public SClass getsClass() { return sClass; }

public void addStudentsMark(Lecture lecture, Double[] value) { studentMarks.put(lecture, value);

}

public List getStudentMarks() {

return studentsMarks; } public void addMark(Double mark){ studentsMarks.add(mark); }

public void setStudentMarks(List studentMarks) { this.studentsMarks = studentMarks; }

@Override public String toString() { return "Student{" + "id=" + getId() + ", name='" + getName() + '\'' + ", dateOfBirth=" + getDateOfBirth() + ", gender=" + getGender() + ", SClass=" + getsClass() + '}'; }

public void setsClass(SClass sClass) { this.sClass = sClass; }

public List getStudentsMarks() { return studentsMarks; }

public void setStudentsMarks(List studentsMarks) { this.studentsMarks = studentsMarks; }

public void setStudentMarks(Map studentMarks) { this.studentMarks = studentMarks; } } ************************************************************************************** package school.model; import java.util.Date; public class Person {

private int id; private String name; private Date dateOfBirth; private Gender gender;

public enum Gender { Male, Female }

public Person(int id, String name, Date dateOfBirth, Gender gender) { this.id = 0; this.name = ""; this.dateOfBirth = dateOfBirth; this.setGender(gender);

}

public int getId() { return id; }

public void setId(int id) { this.id = id; }

public String getName() { return name; }

public void setName(String name) { this.name = name; }

public Date getDateOfBirth() { return dateOfBirth; }

public void setDateOfBirth(Date dateOfBirth) { this.dateOfBirth = dateOfBirth; }

public Gender getGender() { return gender; }

public void setGender(Gender gender) { this.gender = gender; }

@Override public String toString() { return "Person{" + "id=" + id + ", name='" + name + '\'' + ", dateOfBirth=" + dateOfBirth + ", gender=" + gender + '}'; } }

package school.model;

import java.util.ArrayList; import java.util.logging.Level;

public class SClass {

private int id; private int roomNumber; private ArrayList table; private ArrayList books; private ArrayList student; private ArrayList lecture; private String classManager; private Student mangerAssistance; private char section; private static Level level; private Student StudentsMarks;

public SClass(int id, int roomNumber, ArrayList

table, ArrayList books, ArrayList student, ArrayList lecture, String classManager, Student mangerAssistance, char section, Level level, Student studentsMarks) { this.id = id; this.roomNumber = roomNumber; this.table = table; this.books = books; this.student = student; this.lecture = lecture; this.classManager = classManager; this.mangerAssistance = mangerAssistance; this.section = section; this.level = level; this.StudentsMarks = studentsMarks;

}

public SClass(int id) { this.id = id; }

public int getId() { return id; }

public void setId(int id) { this.id = id; }

public int getRoomNumber() { return roomNumber; }

public void setRoomNumber(int roomNumber) { this.roomNumber = roomNumber; }

public ArrayList

getTable() { return table; }

public void setTable(ArrayList

table) { this.table = table; }

public ArrayList getBooks() { return books; }

public void setBooks(ArrayList books) { this.books = books; }

public ArrayList getStudent() { return student; }

public void setStudent(ArrayList student) { this.student = student; }

public ArrayList getLecture() { return lecture; }

public void setLecture(ArrayList lecture) { this.lecture = lecture; }

public String getClassManager() { return classManager; }

public void setClassManager(String classManager) { this.classManager = classManager; }

public Student getMangerAssistance() { return mangerAssistance; }

public void setMangerAssistance(Student mangerAssistance) { this.mangerAssistance = mangerAssistance; }

public void setSection(char section) { this.section = section; }

public Student getStudentsMarks() { return StudentsMarks; }

public void setStudentsMarks(Student studentsMarks) { StudentsMarks = studentsMarks; }

public char getSection() { return section; }

public static Level getLevel() { return level; }

public void setLevel(Level level) { this.level = level; } }

*****************************************

im sorry but The qustion is :

- Make all ids auto generated, like incremental every object created.

- Create toJson, fromJson methods for every model.

In School Control :

- Create method saveSchool to Save the School in file school.json

- Create method importSchool to Import the School from school.json

package school.control; import school.model.Admin; import school.model.Instructor; import school.model.SClass; import school.model.School; import java.util.List; public class SchoolControl { private School school; public SchoolControl(School school) { this.school = school; } public School getSchool() { return school; } public void setSchool(School school) { this.school = school; } public void setAdmin(Admin admin) { school.setAdmin(admin); } public void addSClass(SClass sClass) { List levelSClasses = school.getsClasses().get(sClass.getLevel()); char schoolClassSection = 'a'; schoolClassSection += levelSClasses.size(); sClass.setSection(schoolClassSection); levelSClasses.add(sClass); } public void setAdmin(School admin) { this.school = admin; } public void addInstructor(Instructor instructor) { school.getInstructors().add(instructor); } }

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

Step: 3

blur-text-image

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

Oracle RMAN For Absolute Beginners

Authors: Darl Kuhn

1st Edition

1484207637, 9781484207635

More Books

Students also viewed these Databases questions

Question

2-1. What are six characteristics of effective teams? [LO-1]

Answered: 1 week ago