Java code modification help

I have the following requirement which is due in a day....n as im new to java couldn't understand much. Would b great if sm one can guide me... REQUIREMENT: Modify the code to do the following tasks associated with a list of TV programs for one channel. You should avoid modifying the data structure code as much as possible (UnsortedType for C++, StringLogInterface and ArrayStringLog for Java) Replace the standard datatype (int in the ItemType class, String in the StringLogInterface and ArrayStringLog class) with a class Program which includes: the title of the program (ex: "Revolution", "American Idol") the day of the week when the program is broadcast (Sunday, Monday, Tuesday, etc.) -- assume that each program is shown only one day a week, at one time. the time of the program (ex: 11:30am, 9:00pm) -- you are free to choose how you represent this how long the program lasts, in 30 minute increments (30 minutes, 1 hour, 90 minutes, ...) Write a driver program to run the program. Offer options to: Get the name of the channel for this data -- ex: ABC, HBO 'A' to add a program to your listing. You may assume all inputs are valid, so you don't have to worry about a show on "Funday", for example. You do need to reject the addition if the program overlaps an existing program -- again, this is for only one channel, and we are assuming this is the "regular" schedule, so you don't need to account for programming specials or changes to the schedule. 'P' to print a schedule, ordered by day of the week and then time. Any time slot which does not have a program may be omitted or left blank. Here is what the start of the output might look like: ABC Sunday 8:00am Morning News 9:00am Football pregame 10:00am Football 1:30pm Football postgame 'F' to find a program (ask for the title of the program). If it is found, you should list the program details. If it is not found, display an error message. The three files (interfacefile, arraystring file & the main() file are below as INTERFACE PROGRAM package tvs; public interface stringloginterface { void insert(String element); // Precondition: This StringLog is not full. // // Places element into this StringLog. boolean isFull(); // Returns true if this StringLog is full, otherwise returns false. int size(); // Returns the number of Strings in this StringLog. boolean contains(String element); // Returns true if element is in this StringLog, // otherwise returns false. // Ignores case differences when doing string comparison. void clear(); // Makes this StringLog empty. String getName(); // Returns the name of this StringLog. String toString(); // Returns a nicely formatted string representing this StringLog. } STRING ARRAY PROGRAM package tvs; public class arraystringlog implements stringloginterface { protected String name; // name of this StringLog protected String[] log; // array that holds strings protected int lastIndex = -1; // index of last string in array public arraystringlog(String name, int maxSize) // Precondition: maxSize > 0 // // Instantiates and returns a reference to an empty ArrayStringLog // object with name "name" and room for maxSize strings. { log = new String[maxSize]; this.name = name; } public arraystringlog(String name) // Instantiates and returns a reference to an empty ArrayStringLog // object with name "name" and room for 100 strings. { log = new String[100]; this.name = name; } public void insert(String element) // Precondition: This StringLog is not full. // // Places element into this StringLog. { lastIndex++; log[lastIndex] = element; } public boolean isFull() // Returns true if this StringLog is full, otherwise returns false. { if (lastIndex == (log.length - 1)) return true; else return false; } public int size() // Returns the number of Strings in this StringLog. { return (lastIndex + 1); } public boolean contains(String element) // Returns true if element is in this StringLog, // otherwise returns false. // Ignores case differences when doing string comparison. { int location = 0; while (location <= lastIndex) { if (element.equalsIgnoreCase(log[location])) // if they match return true; else location++; } return false; } public void clear() // Makes this StringLog empty. { for (int i = 0; i <= lastIndex; i++) log[i] = null; lastIndex = -1; } public String getName() // Returns the name of this StringLog. { return name; } public String toString() // Returns a nicely formatted string representing this StringLog. { String logString = "Log: " + name + "\n\n"; for (int i = 0; i <= lastIndex; i++) logString = logString + (i+1) + ". " + log[i] + "\n"; return logString; } } MAIN() program package tvs; public class tvschedule { public static void main(String[] args) { stringloginterface sample; sample = new arraystringlog("Example Use"); sample.insert("Elvis"); sample.insert("King Louis XII"); sample.insert("Captain Kirk"); sample.insert("Nirmal"); sample.insert("Sunaina"); System.out.println(sample); System.out.println("The size of the log is " + sample.size()); System.out.println("Elvis is in the log: " + sample.contains("Elvis")); System.out.println("Santa is in the log: " + sample.contains("Santa")); } } Can some one explain me better on the problem/requirement or the solutuion... thansks in advance

Join the discussion
Be the first to comment on this article. Our Commenting Policies