Instructions for Lab #1: ———————- 1. Create an abstract super class that contains…

Need your ASSIGNMENT done? Use our paper writing service to score better and meet your deadline.


Order a Similar Paper Order a Different Paper

Instructions for Lab #1:
———————-
1. Create an abstract super class that contains common properties and methods
to be inherited by the sub-classes that are provided.
2. Modify your sub-classes to take advantage of this inheritance. Will you
need to re-implement all methods? Will you need to re-declare all
properties?
3. Fix any and all encapsulation problems.
4. Document your code by using Javadoc comments as explained above.
5. Create a startup class to test your code. In this startup class create and
use at least one instance of each sub-class.
6. In the startup class document what you think is good or bad about this
architecture from the perspective of using abstraction and inheritance.
(Remember, a startup class must have a main method)
7. In your test code be sure to adhere to Liskov Substitution principle.

Objectives for Lab #1:
———————
* Practice using abstraction by creating an Abstract super class and
choosing an appropriate class name (should be a noun).
* Practice identifying common properties and behaviors (methods) and placing
those things in the super class
* Practice deciding which super class methods should be abstract, if any,
and which super class methods should be fully implemented, if any.
(TIP: implement methods that should not change and declare them final;
if a method has the potential for being overridden in the sub-clsss,
declare that method abstract)
* Practice documenting your work: all public classes, properties and
methods need Javadoc comments explaining what they are for or what they do.
* Continue practicing what you have learned about Encapsulation

package lab1;

import javax.swing.JOptionPane;

/**
* Describe responsibilities here.
*
* @author your name goes here
* @version 1.00
*/
public class AdvancedJavaCourse {
private String courseName;
private String courseNumber;
private double credits;
private String prerequisites;

public AdvancedJavaCourse(String courseName, String courseNumber) {
this.setCourseName(courseName);
this.setCourseNumber(courseNumber);
}

public String getCourseNumber() {
return courseNumber;
}

public final void setCourseNumber(String courseNumber) {
if(courseNumber == null || courseNumber.length() == 0) {
JOptionPane.showMessageDialog(null,
“Error: courseNumber cannot be null of empty string”);
System.exit(0);
}
this.courseNumber = courseNumber;
}

public double getCredits() {
return credits;
}

public void setCredits(double credits) {
if(credits < 0.5 || credits > 4.0) {
JOptionPane.showMessageDialog(null,
“Error: credits must be in the range 0.5 to 4.0”);
System.exit(0);
}
this.credits = credits;
}

public String getPrerequisites() {
return prerequisites;
}

public void setPrerequisites(String prerequisites) {
if(prerequisites == null || prerequisites.length() == 0) {
JOptionPane.showMessageDialog(null,
“Error: prerequisites cannot be null of empty string”);
System.exit(0);
}
this.prerequisites = prerequisites;
}

public String getCourseName() {
return courseName;
}

public final void setCourseName(String courseName) {
if(courseName == null || courseName.length() == 0) {
JOptionPane.showMessageDialog(null,
“Error: courseName cannot be null of empty string”);
System.exit(0);
}
this.courseName = courseName;
}

}

package lab1;

/**
* Describe responsibilities here.
*
* @author your name goes here
* @version 1.00
*/
public class IntroJavaCourse {
String courseName;
private String courseNumber;
private double credits;
private String prerequisites;

public IntroJavaCourse(String courseName, String courseNumber) {
this.courseName = courseName;
this.courseNumber = courseNumber;
}

public String getCourseNumber() {
return courseNumber;
}

public void setCourseNumber(String courseNumber) {
this.courseNumber = courseNumber;
}

public double getCredits() {
return credits;
}

public void setCredits(double credits) {
this.credits = credits;
}

public String getPrerequisites() {
return prerequisites;
}

public void setPrerequisites(String prerequisites) {
this.prerequisites = prerequisites;
}

}

package lab1;

import javax.swing.JOptionPane;

/**
* Describe responsibilities here.
*
* @author your name goes here
* @version 1.00
*/
public class IntroToProgrammingCourse {
private String courseName;
private String courseNumber;
private double credits;

public IntroToProgrammingCourse(String courseName, String courseNumber) {
this.setCourseName(courseName);
this.setCourseNumber(courseNumber);
}

public String getCourseNumber() {
return courseNumber;
}

public final void setCourseNumber(String courseNumber) {
if(courseNumber == null || courseNumber.length() == 0) {
JOptionPane.showMessageDialog(null,
“Error: courseNumber cannot be null of empty string”);
System.exit(0);
}
this.courseNumber = courseNumber;
}

public double getCredits() {
return credits;
}

public void setCredits(double credits) {
if(credits < 0.5 || credits > 4.0) {
JOptionPane.showMessageDialog(null,
“Error: credits must be in the range 0.5 to 4.0”);
System.exit(0);
}
this.credits = credits;
}

public String getCourseName() {
return courseName;
}

public final void setCourseName(String courseName) {
if(courseName == null || courseName.length() == 0) {
JOptionPane.showMessageDialog(null,
“Error: courseName cannot be null of empty string”);
System.exit(0);
}
this.courseName = courseName;
}

}