Untitled
unknown
plain_text
2 years ago
2.6 kB
9
Indexable
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;
// Data Classes
class AddOrder {
public int orderId;
public String artist;
public double price;
public int quantity;
public AddOrder(int o, String a, double p, int q) {
orderId = o;
artist = a;
price = p;
quantity = q;
}
}
class DeleteOrder {
public int orderId;
public String artist;
public DeleteOrder(int o, String a) {
orderId = o;
artist = a;
}
}
class DeletePriceLevel {
public String artist;
public double price;
public DeletePriceLevel(String a, double p) {
artist = a;
price = p;
}
}
// TODO(candidate): implementation below
class PriceLadder {
public PriceLadder() {
// TODO(candidate): implement
}
public void AddOrder(AddOrder order) {
// TODO(candidate): implement
}
public void DeleteOrder(DeleteOrder delete) {
// TODO(candidate): implement
}
public void DeletePriceLevel(DeletePriceLevel deletePriceLevel) {
// TODO(candidate): implement
}
public void GetPriceLevels(String artist, int numberOfPriceLevels) {
// TODO(candidate): implement
}
}
/**
* The Main class implements an application that reads lines from the standard input
* and prints them to the standard output.
*/
public class Main {
/**
* Iterate through each line of input.
*/
public static void main(String[] args) throws IOException {
InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
BufferedReader in = new BufferedReader(reader);
var priceLadder = new PriceLadder();
String line;
while ((line = in.readLine()) != null) {
var tokens = line.split("\\s+");
if (tokens[0].equals("ADD")) {
priceLadder.AddOrder(new AddOrder(Integer.parseInt(tokens[1]), tokens[2], Integer.parseInt(tokens[3]), Integer.parseInt(tokens[4])));
}
else if (tokens[0].equals("DEL")) {
priceLadder.DeleteOrder(new DeleteOrder(Integer.parseInt(tokens[1]), tokens[2]));
}
else if (tokens[0].equals("DEL_PRICE")) {
priceLadder.DeletePriceLevel(new DeletePriceLevel(tokens[1], Double.parseDouble(tokens[2])));
}
else {
String artist = tokens[0];
var numberOfPriceLevels = Integer.parseInt(tokens[1]);
priceLadder.GetPriceLevels(artist, numberOfPriceLevels);
}
}
}
}
Editor is loading...