I am reletively new to java and have been set some tasks to complete, I (think) I have completed the first two tasks which request I:
- Design a class Manual with the following properties:
serial number - string, - default:??????
title - string, - default: Untitled
author - string, - default: Unknown
Write a constructor and a method to print details of a Manual on the console.
.
- Amend your Manual class by writing the following additional methods:
methods to set and get the properties of a Manual
a method to ask the user for details of a Manual
a toString() method.
Write a simple application to test your additional methods. "
So far, I have this code:
public class Manual {
String serialNumber, title, author;
public static void main(String [] args){
Manual man= new Manual();
man.print();
}
public Manual(){
set("??????", "Untitled", "Unknown");
}
public Manual(String serialNumber, String title, String author)
{
set(serialNumber, title, author);
}
public void set(String serialNumber, String title, String author)
{
this. serialNumber = serialNumber;
this. title = title;
this.author = author;
}
public void print()
{
System.out.println("Serial Number : " +serialNumber);
System.out.println("Title : " +title);
System.out.println("Author : " +author);
}
public void print(String heading)
{
System.out.println(heading);
print();
}
public void ask()
{
serialNumber = Console.askString("Please enter the serial number: ");
title = Console.askString("Please enter the title: ");
author = Console.askString("Please enter the author: ");
set(serialNumber, title, author);
}
public String toString()
{
return serialNumber +" " +title +" " +author +" ";
}
}
Would anyone kindly be able to inform me if I have completed all areas of the first two questions correctly, and if there are any mistakes present in my code?
Thank you