Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer the following questions. From the UML class diagram, answer the following questions: 1. How many superclass and subclass could be derived? List them.

Please answer the following questions.

From the UML class diagram, answer the following questions:

1. How many superclass and subclass could be derived? List them. 2. How the abstract classes able to be conducted? What are the situations to be considered? Explain. 3. How the polymorphism able to be conducted? What are the situations to be considered? Explain. 4. How the interface able to be conducted? What are the situations to be considered? Explain. 5. In writing a code program, is it possible to apply abstract classes and interface? Explain 6. In writing a code program, is it possible to apply abstract classes and polymorphism? Explain

image text in transcribed

class GradedActivity {

private double score;

public void setScore(double s) {

this.score = s;

}

public double getScore() {

return this.score;

}

public char getGrade() {

if (this.score >= 90) {

return 'A';

} else if (this.score >= 80) {

return 'B';

} else if (this.score >= 70) {

return 'C';

} else if (this.score >= 60) {

return 'D';

} else {

return 'F';

}

}

}

class PassFailActivity extends GradedActivity {

protected double minPassingScore;

PassFailActivity(double mps) {

this.minPassingScore = mps;

}

public char getGrade() {

double score = getScore();

if (score >= minPassingScore) {

return 'P';

} else {

return 'F';

}

}

}

class PassFailExam extends PassFailActivity {

private int numQuestions;

private double pointsEach;

private int numMissed;

PassFailExam(int questions, int missed, double minPassing) {

super(minPassing);

this.numQuestions = questions;

this.numMissed = missed;

}

public double getPointsEach() {

return this.pointsEach;

}

public int getNumMissed() {

return this.numMissed;

}

void calculatePoints() {

this.pointsEach = 100.0 / this.numQuestions;

double score = 100 - (this.numMissed * this.pointsEach);

setScore(score);

}

}

public class Main

{

public static void main(String[] args) {

PassFailExam obj = new PassFailExam(100, 20, 55.0);

obj.calculatePoints();

System.out.println("Pass/Fail status: " + obj.getGrade());

System.out.println("Student's score: " + obj.getScore());

}

}

Thank you

Kuala Lumpur Tutorial Consider the following UML Class diagram: GradedActivity This class holds a grade for a graded activity - score : double + setScore (3: double): void + getScore(): double + getGrade(): char Pass FailActivity - minpassingScore : double This class holds numeric score and determines whether the score is passing or failing + Pass FailActivity (mp3: double) + getGrade(): char Pass FailExam This class determines a passing or failing grade for an exam - numQuestions : int - pointsEach : double > Comparable - numMissed : int + equals (g: GradedActivity) + Pass FailExam (questions: int, missed: int, minpassing: double) + getPointsEach(): double + getNumMissed(): int + calculatePoints(): void :boolean

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

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

More Books

Students also viewed these Databases questions

Question

1. The difference between a wholesale bank and a retail bank?

Answered: 1 week ago