// Write a project that demonstrates inheritance in C# //note - there are a lot of distinctions between just being unix and linux, but this is a simplified example, I know. public interface IKernel { //TODO - implement basic functions } public abstract class Unix : IKernel { //TODO - implement basic functions } public class WinNT : IKernel { //TODO - implement basic functions } public class LinuxKernel : Unix { } public class XNU : Unix { } public interface IOperatingSystem { public string DE {get; set;} public string WM {get; set;} public IKernel Kernel {get; set;} void outputSystemSettings(); } public abstract class UnixSystem : IOperatingSystem { public IKernel Kernel {get; set;} public string DE {get; set;} public string WM {get; set;} public void outputSystemSettings() {} protected UnixSystem(string DesktopEnvironment, string WindowManager, IKernel kernel) { this.DE = DesktopEnvironment; this.WM = WindowManager; this.Kernel = kernel; } } public class MacOs : UnixSystem { // this info was taken with neofetch on my computer public MacOs() : base("Aqua", "Quartz Compositor", new XNU()) {} } public class Ubuntu : UnixSystem { //defaults are used here, since linux is extremely customizable public Ubuntu() : base("GNOME", "Metacity", new LinuxKernel()) {} } public class Windows : IOperatingSystem { public string DE {get; set;} = "Windows Shell"; public string WM {get; set;} = "DWM"; public IKernel Kernel {get; set;} = new WinNT(); public void outputSystemSettings() { } }
// Write a project that demonstrates inheritance in C#- // Write a project that demonstrates inheritance in C#
- //note - there are a lot of distinctions between just being unix and linux, but this is a simplified example, I know.
- public interface IKernel {
- //TODO - implement basic functions
- }
- public abstract class Unix : IKernel {
- //TODO - implement basic functions
- }
- public class WinNT : IKernel {
- //TODO - implement basic functions
- }
- public class LinuxKernel : Unix {
- }
- public class XNU : Unix {
- }
- public interface IOperatingSystem {
- public string DE {get; set;}
- public string WM {get; set;}
- public IKernel Kernel {get; set;}
- void outputSystemSettings();
- }
- public abstract class UnixSystem : IOperatingSystem {
- public IKernel Kernel {get; set;}
- public string DE {get; set;}
- public string WM {get; set;}
- public void outputSystemSettings() {}
- protected UnixSystem(string DesktopEnvironment, string WindowManager, IKernel kernel) {
- this.DE = DesktopEnvironment;
- this.WM = WindowManager;
- this.Kernel = kernel;
- }
- }
- public class MacOs : UnixSystem {
- // this info was taken with neofetch on my computer
- public MacOs() : base("Aqua", "Quartz Compositor", new XNU()) {}
- }
- public class Ubuntu : UnixSystem {
- //defaults are used here, since linux is extremely customizable
- public Ubuntu() : base("GNOME", "Metacity", new LinuxKernel()) {}
- }
- public class Windows : IOperatingSystem {
- public string DE {get; set;} = "Windows Shell";
- public string WM {get; set;} = "DWM";
- public IKernel Kernel {get; set;} = new WinNT();
- public void outputSystemSettings() {
- }
- }
function prime_checker (n) { if (n <= 1) return false; // negatives if (n % 2 === 0 && n > 2) return false; //if even, we can immediately say it's composite. const sq = Math.sqrt(n) for (let i = 3; i<sq; i+= 2) { if (n % i == 0) return false; } return true; }
- function prime_checker (n) {
// Write a javascript function to check if N is a prime number- if (n <= 1) return false; // negatives
- if (n % 2 === 0 && n > 2) return false; //if even, we can immediately say it's composite.
- const sq = Math.sqrt(n)
- for (let i = 3; i<sq; i+= 2) {
- if (n % i == 0) return false;
- }
- return true;
- }
2nd revision of this project. i'm still trying to figure out exactly what's wrong and how to get the test results. There's some errors with the lowercase/uppercase types? Either way, it iterates first to count elements (there's a way to optimize it but i'm very tired) and then only adds the second element.
import static java.util.stream.DoubleStream.of; import static org.apache.commons.lang3.ArrayUtils.reverse; import java.util.Arrays; interface DeleteDuplicates { static Double[] deleteDups(double[] nums) { // Given an array, eliminate duplicate values and return the array // also - only returns the last values Map<Double, Integer> amountOfTimesSeen = new HashMap<Double, Integer>(); ArrayList<Double> tempArray = new ArrayList<Double>(); //this is a very hacky thing and i'd optimize things but i dont have time //first iterate through everything to see how many times we get a number for (double num: nums) { if (amountOfTimesSeen.putIfAbsent(num, 1) != null) { amountOfTimesSeen.put(num, amountOfTimesSeen.get(num) + 1); } } //now add to the temporary array if it's only been in the array once for (double num: nums) { if (amountOfTimesSeen.get(num) == 1) { tempArray.add(num); } if (amountOfTimesSeen.get(num) == 2) { amountOfTimesSeen.put(num, amountOfTimesSeen.get(num) - 1); //im literally praying this works. idk what it does but whatever. } } return tempArray.toArray(new Double[tempArray.size()]); } }
- import static java.util.stream.DoubleStream.of;
- import static org.apache.commons.lang3.ArrayUtils.reverse;
- import java.util.Arrays;
- interface DeleteDuplicates {
static double[] deleteDups(double[] a) {// Given an array, eliminate duplicate values and return the arrayreturn a;}- static Double[] deleteDups(double[] nums) {
- // Given an array, eliminate duplicate values and return the array
- // also - only returns the last values
- Map<Double, Integer> amountOfTimesSeen = new HashMap<Double, Integer>();
- ArrayList<Double> tempArray = new ArrayList<Double>();
- //this is a very hacky thing and i'd optimize things but i dont have time
- //first iterate through everything to see how many times we get a number
- for (double num: nums) {
- if (amountOfTimesSeen.putIfAbsent(num, 1) != null) {
- amountOfTimesSeen.put(num, amountOfTimesSeen.get(num) + 1);
- }
- }
- //now add to the temporary array if it's only been in the array once
- for (double num: nums) {
- if (amountOfTimesSeen.get(num) == 1) {
- tempArray.add(num);
- }
- if (amountOfTimesSeen.get(num) == 2) {
- amountOfTimesSeen.put(num, amountOfTimesSeen.get(num) - 1);
- //im literally praying this works. idk what it does but whatever.
- }
- }
- return tempArray.toArray(new Double[tempArray.size()]);
- }
- }
import static java.util.stream.DoubleStream.of; import static org.apache.commons.lang3.ArrayUtils.reverse; import java.util.*; interface DeleteDuplicates { static double[] deleteDups(double[] nums) { return Arrays.stream(nums).distinct().toArray(); } }
import static java.util.stream.DoubleStream.of;- import static java.util.stream.DoubleStream.of;
- import static org.apache.commons.lang3.ArrayUtils.reverse;
- import java.util.*;
- interface DeleteDuplicates {
static double[] deleteDups(double[] a) {// Given an array, eliminate duplicate values and return the arrayreturn a;}- static double[] deleteDups(double[] nums) {
- return Arrays.stream(nums).distinct().toArray();
- }
- }