CarpetParser

CarpetParser - String tokens =...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
// Assignment #: 5 // Name: To be completed // StudentID: To be completed // Lecture: To be completed // Description: The Assignment 5 class displays a menu of choices // (add carpet, compute total prices, search carpet, // list carpets, quit, display menu) to a user // and performs the chosen task. It will keep asking a user to // enter the next choice until the choice of 'Q' (Quit) is // entered. / public final class CarpetParser { public static Carpet parseStringToCarpet(String lineToParse) { Carpet carpet= null;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: String tokens = lineToParse.split("/"); if (tokens[0].equals ("Rectangle")) { String cId=tokens[1]; double uprice=Double.parseDouble (tokens[2]); int w= Integer.parseInt(tokens[3]); int h= Integer.parseInt(tokens[4]); carpet= new RectangleCarpet(cId, uprice, w, h); } else if(tokens[0].equals ("Circle")) { String cId=tokens[1]; double uprice=Double.parseDouble (tokens[2]); int rad= Integer.parseInt(tokens[3]); carpet= new CircleCarpet(cId, uprice, rad); } return carpet; } }...
View Full Document

Ask a homework question - tutors are online