Question
Please use the following files as a template and edit them for the answer. Student: public class Student { private String fullName, asuID; private double
Please use the following files as a template and edit them for the answer.
Student:
public class Student { private String fullName, asuID; private double grade; private int numOfUpdates, numOfAccessed;
private String studentName; //default constructor public Student() { this.asuID = null; this.fullName = null; this.grade = -1; // an impossible value to say it's N/A this.numOfUpdates = 0; this.numOfAccessed = 0; } //overloaded constructor public Student(String fullName, String asuID, double grade) { this.asuID = asuID; this.grade = grade; this.fullName = fullName; this.numOfUpdates = 0; this.numOfAccessed = 0; }
public boolean equals(Student other) { // Check whether two objects have available asuID if (this.asuID != null && other.asuID != null) { if (this.asuID.equals(other.asuID)) { return true; } } else if (this.fullName != null && other.fullName != null) {
}
return false; } //return student's info public String toString() { return String.format("[Name: %s, ASUID: %s, Grade: %.2f]", fullName, asuID, grade); } //mutator method public void setName(String fullName) { this.fullName = fullName; } //mutator methods public void setId(String id) { }
public void setGrade(double grade) { } //accessor methods public String getFullname() { return ""; } / public String getAsuID() { return asuID; }
public double getGrade() { return -1; }
public int getNumOfUpdates() { return numOfUpdates; }
public int getNumOfAccessed() { return numOfAccessed; } }
Program:
import java.time.LocalDateTime;
public class Program { private String programName, description, createdDate, fileName; private Student author;
public Program(String programName, String description, String fileName, Student author) { this.programName = programName; this.description = description; this.fileName = fileName; this.author = author; this.createdDate = LocalDateTime.now().toString(); }
public String toString() { return String.format("Program: %s, Desc: %s, Filename: %s, Author: %s", programName, description, fileName, author.toString()); }
public String getProgramName() { return programName; }
public String getDescription() { return description; }
public String getCreatedDate() { return createdDate; }
public String getFileName() { return fileName; }
public Student getAuthor() { return author; } }
Lab7:
import java.util.Scanner; public class Lab7 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String sFirstname, sLastname, sAsuID; double sGrade; String pName, pDesc, pFname;
// Read some input data println("The student's first name?"); sFirstname = scan.nextLine(); println("The student's last name?"); sLastname = scan.nextLine(); println("The student's ASU ID?"); sAsuID = scan.nextLine(); println("Program name?"); pName = scan.nextLine(); println("Program desc?"); pDesc = scan.nextLine(); println("Program filename?"); pFname = scan.nextLine(); println("Program grade?"); sGrade = scan.nextDouble(); scan.nextLine(); println(""); scan.close();
// Create a Student object "student1"
// Use the setGrade setter to set student1's grade
// Create a Program object "program1" by "student1" Program program1 = new Program(pName, pDesc, pFname, student1); System.out.println("Making a program record ...[" + program1 + "]");
// Invoke makeReport to show the report of student1
}
private static void makeReport(Program program) { println(" ========== Program Submission Detail =========="); pprint("Student", program.getAuthor().getFullName()); pprint("ASU ID", program.getAuthor().getAsuID()); pprint("Grade", "" + program.getAuthor().getGrade()); println(""); pprint("Program", program.getProgramName()); pprint("Filename", program.getFileName()); pprint("Description", program.getDescription()); pprint("Datetime", program.getCreatedDate()); }
private static void pprint(String key, String value) { println(String.format("%-12s: %-10s", key, value)); }
private static void println(String s) { System.out.println(s); } }
Lab Topics . Designing a Class and using Objects (OOP) Methods and Attributes Understanding the use of visibility modifier Lab Problem: Designing an AutoGrader Grading computer programs is an extremely tedious and complex task. One core problem in this task is how to manage students' records and programs efficiently. In this and the following lab classes, you will design a real and working productivity tool that can help teachers to help with grading students' assignments. In Lab 7, your job is to use three classes that will become the building blocks of Lab7, which are Lab7, Program, and Student. Lab7 is the main driver of this program. Program and Student classes are two custom data types that help the user to save and organize information in the program. The structures of these classes are shown in the following UML class diagrams. Labo + main(args: String(): void + makeReport(program: Program): void Program Student programName: String description: String createdDate: String fileName: String author: Student firstName: String lastName: String fullName: String asuld: String grade: double + Program(name: String, desc: String, filename: String, author: Student) + Getters of all the attributes + toString(): String + Student(fname: String, Iname: String, asuld: String) + Getters of all the attributes + toString(): String + setGrade(newGrade: double): void Your program will do the following things: 1. Read a student's record and the program's details from the input 2. Create Student and Program objects to save the record into Java 3. Make a report in a structured format that can be filed in the future. Hints & Notes . The input function and some helper functions have been given in the Lab7.java file. You may still create your own Lab7.java as a practice. Study the code and try to understand what we expect the program to do. You will see a lot of errors in the original Lab7.java because variables and classes are not defined o You will need to put in your own code in the main function in Lab7.java You will need to create ONE class by yourself, Student (Student.java), and supply the required attributes and methods. The class Program.java is provided 0 O Sample Output Below is an example of what your output should roughly look like when this lab is completed. Text in RED represents user input. The student's first name? Teaching The student's last name? Assistant The student's ASU ID? 10291029 Program name? CSE110 Lab 7 Program desc? Custom classes/data types for the AutoGrader project. Program filename? Lab7.java Program grade? 9 Making a student record ... [Student: Teaching Assistant, ASUID: 10291029, Grade: -1.00] Making a program record ... [Program: CSE110 Lab 7, Desc: Custom classes/data types for the AutoGrader project., Filename: Lab7.java, Author: Student: Teaching Assistant, ASUID: 10291029, Grade: 9.00] ========== Student ASU ID Grade Program Submission Detail ========== : Teaching Assistant : 10291029 : 9.0 Program : CSE110 Lab 7 Filename : Lab7.java Description : Custom classes/data types for the AutoGrader project. Datetime : 2019-02-23T15:37:36.188587Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started