This is my first programming assignment, so I'm obviously a novice. The criteria of my assignment is to create an assignment class that takes in 4 variables. Then I am to make a program that accepts user's input for those variable, and then creates an objects, using previously ascribed getter methods.
AssignmentCreator Class
This class will use the Assignment class to create an assignment.
First, ask the user to enter the title, category, max points, and due date for the assignment.
Create an object of the Assignment class using the argument constructor and the user’s input.
Using the getter methods, display the assignment’s information, as shown below. The output that should be produced by this class is shown below in the sample execution section.
My initial Assignment class file:
/**
Describes an assignment's title, due date, total points value, and category
*/
public class Assignment
{
private String title; //Title of assignment
private String dueDate; //Due date of assignment
private double maxPoints; //Max points of assignment
private String category; //Category of assignment
/**
Initialize instance variables for assignment project (no argument-constructor)
*/
public Assignment()
{
title = "Assignment 1";
dueDate = "01/01/2019";
maxPoints = 10.0;
category = "Programming Assignments";
}
/**
Initialize instance variables for the assignment project (argument constructor)
@param t title of assignment
@param d due date of assignment
@param m max points for the assignment
@param c category of assignment
*/
public Assignment(String t, String d, double m,String c)
{
title = t;
dueDate = d;
maxPoints = m;
category = c;
}
/**
Sets the value of title
@param t title of assignment
*/
public void setTitle(String t)
{
title = t;
}
/**
Sets the value of dueDate
@param d due date of assignment
*/
public void setDueDate(String d)
{
dueDate = d;
}
/**
Sets value of maxPoints
@param m max points of assignment
*/
public void setMaxPoints(double m)
{
maxPoints = m;
}
/**
Sets the value of category
@param c category of assignment
*/
public void setCategory(String c)
{
category = c;
}
/**
Returns the value of title
@return title of assingment
*/
public String getTitle()
{
return title;
}
/**
Returns the value of dueDate
@return due date of assignment
*/
public String getDueDate()
{
return dueDate;
}
/**
Returns the value of maxPoints
@return max points of assignment
*/
public double getMaxPoints()
{
return maxPoints;
}
/**
Returns the value of category
@return category of assingmen
*/
public String getCategory()
{
return category;
}
}
This is where I am currently stuck:
/**
imports scanner used for user import
*/
import java.util.Scanner;
public class AssignmentCreator
{
public static void main(String[] args)
{
Scanner S = new Scanner(System.in);
System.out.print("Create Assignment \n=================\n\n");
System.out.print("Enter title: ");
String t = S.nextLine();
System.out.print("Enter category: ");
String c = S.nextLine();
System.out.print("Enter max points: ");
double m = S.nextDouble();
System.out.print("Enter due date (MM/DD/YYYY): ");
String d = S.nextLine();
Assignment create = new Assignment(t, c, m, d);
System.out.print("Title of the assignment is: " + create.getTitle());
System.out.print("category of the assignment is: " + create.getCategory());
System.out.print("max points of the assignment is: " + create.getMaxPoints());
System.out.print("due date of the assignment is: " + create.getDueDate());
Now, I know that this correctly asks for input and stores it to 4 variables, but I'm confused as to how to do as the instructions above say.
I also understand how "System.out.println("| Category | " + c);" etc. would create and show what was stored, but thats not exactly what I was instructed to do.