Task
You are working for NoVirus Security Solutions and they ask you to make a scanner that scans a file inputted by the user with the function scanFile(File,VirusDB) that takes a File and a VirusDB object and return whether a file is safe or not. Remember: the searches need to be non-Case-Sensitive
Your class also has the function setScanIntensity(int) which changes the scan intensity. This will only receive values 0, 1, 2 or 3. This has been done for you.
The scan intensity determines the arrays from the database that will be used. i.e.:
scanIntensity 0 means off(every file is considered safe)
scanIntensity 1 means that only the array intensity1Signatures will be used
scanIntensity 2 means that the arrays intensity1Signatures and intensity2Signatures will be used
scanIntensity 3 means that all 3 arrays will be used
Outputs
The outputs should be: "Filename is safe" or "Filename is not safe" (Filename is the name of the file that you can get with file.getName() )
File Class
class File{ private String name; private String data; public File(String name,String data){ this.name = name; this.data = data; } //used in output public String getName(){ return this.name; } //the String that you need to scan. public String getData(){ return this.data; } }
VirusDB Class
class VirusDB{ private String[] intensity1Signatures; private String[] intensity2Signatures; private String[] intensity3Signatures; public VirusDB(String[] intensity1Signatures,String[] intensity2Signatures,String[] intensity3Signatures){ this.intensity1Signatures = intensity1Signatures; this.intensity2Signatures = intensity2Signatures; this.intensity3Signatures = intensity3Signatures; } public String[] getSignatures(int arrayNum){ switch (arrayNum){ case 1:return this.intensity1Signatures; case 2:return this.intensity2Signatures; case 3:return this.intensity3Signatures; default:return new String[0]; } } }
Examples
String[] intensity1signatures = new String[]{ "malware", "virus", "infect" }; String[] intensity2signatures = new String[]{ "ransomware", "trojan", "trojanHorse", "worm", "spyware", "keystrokelogger", "adware", "botnet", "rootkit", }; String[] intensity3signatures = new String[]{ "DeleteSys32", "OverideMBR", "EncryptAll", "openrandomwebsite", "openrandwebsite", "sendalldata", "recordKeyboard", "recordmouse", "destroy", "overheat", "getfullcontrol", "uploadharddrive", "uploadharddisk", "overload", "changeOS", "encrypt", "changeDesktop", "ddos", "dos", "hide", "inject", "ransom", "getcreditcardinfo", "getpasswords", "getpass", };
'매일매일개발 > Codewars' 카테고리의 다른 글
codewars #70 IQ Test (6kyu) (0) | 2018.07.02 |
---|---|
codewars #69 Weight for weight (5kyu) (0) | 2018.06.28 |
codewars #67 Predict your age! (7kyu) (0) | 2018.06.26 |
codewars #66 Inside Out Strings (6kyu) (0) | 2018.06.22 |
codewars #65 Split Strings (6kyu) (0) | 2018.06.21 |