All the information is stored in commaseparated files:
See figure. Users.txt, Cart.txt, Books.txt, Ebooks.txt, CDs.txt, and MP3.txt
public abstract class Item{
public abstract String getInfo(...);
public abstract int getPrice(...);
protected int price;
protected int sNo; /
/ Add other fields if necessary
}
public class Readable extends Item {
protected String authorName;
public String getInfo(...){...} //Returns sNo, Name, Author name, etc in a string
@Override
public int getPrice(...){ // override
…
}
}
public class Book extends Readable {
…
@Override
public int getPrice(...){ // override to get the item price and add 2% (Environment Tax)
…
}
}
public class eBook extends Readable{
@Override
public int getPrice(...){ // override and only call the parent’s constructor to get the base price.
…
}
public class Audio extends Item {
protected String artistName;
public String getInfo(...){...} //Returns sNo, Name, Artist name, etc in a string
@Override
public int getPrice(...){ // override
…
…
}
public class CD extends Audio {
…
@Override
public int getPrice(...){ // override to get the item price and add 2% (Environment Tax)
…
}
}
public class MP3 extends Audio{
@Override
public int getPrice(...){ // override and only call the parent’s getPrice() to get the base price.
…
}
public class User{
private String username;
public String getUsername(...){ // stores the username.
…
}
public class ShoppingCart extends User {
private content //array of items
public String getContent(...){// return the content of the shopping cart
public addItem (...){}
}
public class UserInterface{
private array readables;
private array audioProducts;
private int currentPage; // the page number (P1..P10)
public int getCurrentPage(...){ // This method is for page navigation. Based on the values of the state variable, call different pages
public int changeCurrentPage(...){ // This method is for page navigation. It should change to current page and show the content.
public void getReadables(); // Fetches all readables from the files and places them in the readables array
public void getAudioProducts(); // Fetches all audio products from the files and places them in the readables array
public void showReadables(); // Displays all readables for browsing
public void showAudioProducts(); // Displays all audio products for browsing
…
}