w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Add manual & print manual details - Java

in my logical way, think it'd have been better in this ways

/// Library Class

import java.util.*;



public class Library 
{


public static void main(String[] args) 
{

String serialNumber, title, author;


Scanner input = new Scanner(System.in);


System.out.print("Please enter the serial number: ");
serialNumber = input.next();

System.out.print("Please enter the title: ");
title= input.next();

System.out.print("Please enter the author: ");
author = input.next();

Manual man= new Manual(serialNumber,title,author);

man.print();


}


}

/// Manual Class

public class Manual 
{
String serialNumber, title, author;


public Manual(String serialNumber, String title, String author)
{
setSerialNumber(serialNumber);
setTitle(title);
setAuthor(author);
}

//// serial number

public void setSerialNumber(String number)
{
serialNumber = number;
}


public String getserialNumber()
{
return serialNumber;
}

public void setTitle(String mytitle)
{
    title = mytitle;
}
public String getTitle()
{
    return title;
}

public void setAuthor(String myAuthor)
{
author = myAuthor;
}
public String getAuthor()
{
return 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);
printing();
}


public String toString()
{
return "SerialNumber: " + serialNumber +"
"
+"Title: " + title + "
" 
+"Author: " + author +"
";
}

public void printing()
{
System.out.println(this.toString());

}
}

and as an advice, always do simple things, simple but logical code. i'm also a beginner like you. that's what i've always been told

hope it was helpful





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.